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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-05-20 20:52:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-05-20 20:52:10 +0400
commit88f4087a574c2f74b3414d47dab8be97cce4bc84 (patch)
treef1440d4aa18d73c4d1449857ccabefc444d867e2
parent4514be8f4ff5c87824e447c7016939363f66f78c (diff)
parent259582235c5dc211f998e2c1924faae6c9b7a87e (diff)
svn merge -r36725:36801 https://svn.blender.org/svnroot/bf-blender/trunk/blender
-rw-r--r--build_files/buildbot/config/user-config-i686.py3
-rw-r--r--build_files/buildbot/config/user-config-x86_64.py3
-rw-r--r--release/scripts/modules/bpy/path.py2
-rw-r--r--release/scripts/modules/bpy/utils.py4
-rw-r--r--release/scripts/modules/bpy_extras/__init__.py2
-rw-r--r--release/scripts/modules/bpy_extras/view3d_utils.py41
-rw-r--r--release/scripts/startup/bl_ui/__init__.py3
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py2
-rw-r--r--release/scripts/startup/bl_ui/space_userpref_keymap.py2
-rw-r--r--source/blender/blenkernel/BKE_icons.h8
-rw-r--r--source/blender/blenkernel/BKE_object.h1
-rw-r--r--source/blender/blenkernel/BKE_screen.h3
-rw-r--r--source/blender/blenkernel/BKE_subsurf.h2
-rw-r--r--source/blender/blenkernel/BKE_world.h1
-rw-r--r--source/blender/blenkernel/intern/action.c5
-rw-r--r--source/blender/blenkernel/intern/blender.c32
-rw-r--r--source/blender/blenkernel/intern/fcurve.c2
-rw-r--r--source/blender/blenkernel/intern/icons.c22
-rw-r--r--source/blender/blenkernel/intern/material.c3
-rw-r--r--source/blender/blenkernel/intern/multires.c4
-rw-r--r--source/blender/blenkernel/intern/object.c29
-rw-r--r--source/blender/blenkernel/intern/screen.c18
-rw-r--r--source/blender/blenkernel/intern/sequencer.c17
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c2
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c11
-rw-r--r--source/blender/blenkernel/intern/world.c30
-rw-r--r--source/blender/blenlib/BLI_math_geom.h12
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h2
-rw-r--r--source/blender/blenlib/BLI_utildefines.h2
-rw-r--r--source/blender/blenlib/intern/bpath.c321
-rw-r--r--source/blender/blenlib/intern/math_geom.c48
-rw-r--r--source/blender/blenlib/intern/math_matrix.c6
-rw-r--r--source/blender/blenloader/BLO_readfile.h14
-rw-r--r--source/blender/blenloader/BLO_writefile.h2
-rw-r--r--source/blender/blenloader/intern/readblenentry.c59
-rw-r--r--source/blender/blenloader/intern/readfile.c116
-rw-r--r--source/blender/blenloader/intern/readfile.h4
-rw-r--r--source/blender/blenloader/intern/writefile.c30
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c8
-rw-r--r--source/blender/editors/animation/anim_ops.c9
-rw-r--r--source/blender/editors/animation/keyingsets.c3
-rw-r--r--source/blender/editors/armature/editarmature.c70
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c8
-rw-r--r--source/blender/editors/armature/poselib.c2
-rw-r--r--source/blender/editors/curve/editcurve.c15
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c80
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c39
-rw-r--r--source/blender/editors/include/ED_keyframing.h3
-rw-r--r--source/blender/editors/include/ED_view3d.h92
-rw-r--r--source/blender/editors/interface/interface_handlers.c17
-rw-r--r--source/blender/editors/interface/interface_layout.c6
-rw-r--r--source/blender/editors/interface/view2d.c12
-rw-r--r--source/blender/editors/interface/view2d_ops.c13
-rw-r--r--source/blender/editors/mesh/editbmesh_bvh.c8
-rwxr-xr-xsource/blender/editors/mesh/knifetool.c4
-rw-r--r--source/blender/editors/physics/particle_edit.c19
-rw-r--r--source/blender/editors/render/CMakeLists.txt2
-rw-r--r--source/blender/editors/render/render_intern.h11
-rw-r--r--source/blender/editors/render/render_internal.c412
-rw-r--r--source/blender/editors/render/render_opengl.c2
-rw-r--r--source/blender/editors/render/render_preview.c500
-rw-r--r--source/blender/editors/render/render_shading.c175
-rw-r--r--source/blender/editors/render/render_update.c238
-rw-r--r--source/blender/editors/render/render_view.c359
-rw-r--r--source/blender/editors/screen/area.c8
-rw-r--r--source/blender/editors/screen/screen_ops.c9
-rw-r--r--source/blender/editors/screen/screendump.c111
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c41
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h4
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c10
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c11
-rw-r--r--source/blender/editors/space_action/action_select.c21
-rw-r--r--source/blender/editors/space_buttons/buttons_header.c32
-rw-r--r--source/blender/editors/space_buttons/buttons_intern.h3
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c2
-rw-r--r--source/blender/editors/space_file/file_ops.c4
-rw-r--r--source/blender/editors/space_file/filelist.c7
-rw-r--r--source/blender/editors/space_graph/graph_draw.c2
-rw-r--r--source/blender/editors/space_graph/graph_ops.c11
-rw-r--r--source/blender/editors/space_graph/graph_select.c35
-rw-r--r--source/blender/editors/space_graph/space_graph.c15
-rw-r--r--source/blender/editors/space_image/image_ops.c5
-rw-r--r--source/blender/editors/space_image/space_image.c28
-rw-r--r--source/blender/editors/space_logic/space_logic.c13
-rw-r--r--source/blender/editors/space_nla/nla_channels.c8
-rw-r--r--source/blender/editors/space_nla/nla_select.c21
-rw-r--r--source/blender/editors/space_nla/space_nla.c17
-rw-r--r--source/blender/editors/space_node/node_edit.c17
-rw-r--r--source/blender/editors/space_node/node_select.c22
-rw-r--r--source/blender/editors/space_node/node_state.c10
-rw-r--r--source/blender/editors/space_node/space_node.c13
-rw-r--r--source/blender/editors/space_outliner/outliner.c16
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c8
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c3
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c15
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c13
-rw-r--r--source/blender/editors/space_text/text_header.c14
-rw-r--r--source/blender/editors/space_time/space_time.c12
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c2
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c21
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c32
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c119
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c7
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c144
-rw-r--r--source/blender/editors/transform/transform.c11
-rw-r--r--source/blender/editors/transform/transform.h2
-rw-r--r--source/blender/editors/transform/transform_conversions.c2
-rw-r--r--source/blender/editors/transform/transform_generics.c15
-rw-r--r--source/blender/editors/transform/transform_input.c5
-rw-r--r--source/blender/editors/transform/transform_manipulator.c2
-rw-r--r--source/blender/editors/transform/transform_ops.c20
-rw-r--r--source/blender/editors/transform/transform_snap.c4
-rw-r--r--source/blender/editors/util/undo.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c29
-rw-r--r--source/blender/imbuf/intern/png.c2
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h9
-rw-r--r--source/blender/makesrna/RNA_access.h5
-rw-r--r--source/blender/makesrna/RNA_define.h2
-rw-r--r--source/blender/makesrna/RNA_types.h6
-rw-r--r--source/blender/makesrna/intern/makesrna.c132
-rw-r--r--source/blender/makesrna/intern/rna_ID.c6
-rw-r--r--source/blender/makesrna/intern/rna_access.c50
-rw-r--r--source/blender/makesrna/intern/rna_animation.c10
-rw-r--r--source/blender/makesrna/intern/rna_define.c3
-rw-r--r--source/blender/makesrna/intern/rna_internal.h4
-rw-r--r--source/blender/makesrna/intern/rna_internal_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_render.c8
-rw-r--r--source/blender/makesrna/intern/rna_scene.c6
-rw-r--r--source/blender/makesrna/intern/rna_screen.c59
-rw-r--r--source/blender/makesrna/intern/rna_space.c19
-rw-r--r--source/blender/makesrna/intern/rna_ui.c42
-rw-r--r--source/blender/makesrna/intern/rna_wm.c34
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c6
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c10
-rw-r--r--source/blender/python/generic/mathutils_Matrix.c24
-rw-r--r--source/blender/python/generic/mathutils_geometry.c55
-rw-r--r--source/blender/python/intern/bpy_rna.c17
-rw-r--r--source/blender/render/extern/include/RE_pipeline.h20
-rw-r--r--source/blender/render/intern/source/rendercore.c40
-rw-r--r--source/blender/windowmanager/WM_api.h4
-rw-r--r--source/blender/windowmanager/intern/wm.c5
-rw-r--r--source/blender/windowmanager/intern/wm_files.c52
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c11
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c16
-rw-r--r--source/blender/windowmanager/wm.h2
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp6
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp5
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp4
151 files changed, 2304 insertions, 2334 deletions
diff --git a/build_files/buildbot/config/user-config-i686.py b/build_files/buildbot/config/user-config-i686.py
index 7c7e779bdb2..1ad6c5d22fe 100644
--- a/build_files/buildbot/config/user-config-i686.py
+++ b/build_files/buildbot/config/user-config-i686.py
@@ -29,7 +29,8 @@ BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/
'${BF_FFMPEG_LIBPATH}/libxvidcore.a ${BF_FFMPEG_LIBPATH}/libx264.a ${BF_FFMPEG_LIBPATH}/libmp3lame.a ' + \
'${BF_FFMPEG_LIBPATH}/libvpx.a ${BF_FFMPEG_LIBPATH}/libvorbis.a ${BF_FFMPEG_LIBPATH}/libogg.a ' + \
'${BF_FFMPEG_LIBPATH}/libvorbisenc.a ${BF_FFMPEG_LIBPATH}/libtheora.a ' + \
- '${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ${BF_FFMPEG_LIBPATH}/liborc-0.4.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a'
+ '${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ${BF_FFMPEG_LIBPATH}/liborc-0.4.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a ' + \
+ '${BF_FFMPEG_LIBPATH}/libfaad.a'
# Don't depend on system's libstdc++
WITH_BF_STATICCXX = True
diff --git a/build_files/buildbot/config/user-config-x86_64.py b/build_files/buildbot/config/user-config-x86_64.py
index 04489c7d06c..3eaadd99d45 100644
--- a/build_files/buildbot/config/user-config-x86_64.py
+++ b/build_files/buildbot/config/user-config-x86_64.py
@@ -29,7 +29,8 @@ BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/
'${BF_FFMPEG_LIBPATH}/libxvidcore.a ${BF_FFMPEG_LIBPATH}/libx264.a ${BF_FFMPEG_LIBPATH}/libmp3lame.a ' + \
'${BF_FFMPEG_LIBPATH}/libvpx.a ${BF_FFMPEG_LIBPATH}/libvorbis.a ${BF_FFMPEG_LIBPATH}/libogg.a ' + \
'${BF_FFMPEG_LIBPATH}/libvorbisenc.a ${BF_FFMPEG_LIBPATH}/libtheora.a ' + \
- '${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ${BF_FFMPEG_LIBPATH}/liborc-0.4.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a'
+ '${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ${BF_FFMPEG_LIBPATH}/liborc-0.4.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a ' + \
+ '${BF_FFMPEG_LIBPATH}/libfaad.a'
# Don't depend on system's libstdc++
WITH_BF_STATICCXX = True
diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py
index f7e5b988cc8..5e95428f641 100644
--- a/release/scripts/modules/bpy/path.py
+++ b/release/scripts/modules/bpy/path.py
@@ -135,7 +135,7 @@ def resolve_ncase(path):
filename = os.path.basename(path) # filename may be a directory or a file
dirpath = os.path.dirname(path)
- suffix = ""
+ suffix = path[:0] # "" but ensure byte/str match
if not filename: # dir ends with a slash?
if len(dirpath) < len(path):
suffix = path[:len(path) - len(dirpath)]
diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py
index a2d7b9e502f..7c0d3d24cba 100644
--- a/release/scripts/modules/bpy/utils.py
+++ b/release/scripts/modules/bpy/utils.py
@@ -379,7 +379,9 @@ def preset_find(name, preset_path, display_name=False):
def keyconfig_set(filepath):
from os.path import basename, splitext
- print("loading preset:", filepath)
+ if _bpy.app.debug:
+ print("loading preset:", filepath)
+
keyconfigs = _bpy.context.window_manager.keyconfigs
keyconfigs_old = keyconfigs[:]
diff --git a/release/scripts/modules/bpy_extras/__init__.py b/release/scripts/modules/bpy_extras/__init__.py
index e124d3c5b3d..06d41fa670e 100644
--- a/release/scripts/modules/bpy_extras/__init__.py
+++ b/release/scripts/modules/bpy_extras/__init__.py
@@ -28,4 +28,4 @@ __all__ = (
"image_utils",
"mesh_utils",
"view3d_utils",
-) \ No newline at end of file
+)
diff --git a/release/scripts/modules/bpy_extras/view3d_utils.py b/release/scripts/modules/bpy_extras/view3d_utils.py
index 15f5aaa20b7..7d37b94982f 100644
--- a/release/scripts/modules/bpy_extras/view3d_utils.py
+++ b/release/scripts/modules/bpy_extras/view3d_utils.py
@@ -36,12 +36,19 @@ def region_2d_to_vector_3d(region, rv3d, coord):
"""
from mathutils import Vector
- dx = (2.0 * coord[0] / region.width) - 1.0
- dy = (2.0 * coord[1] / region.height) - 1.0
+ if rv3d.is_perspective:
+ persinv = rv3d.perspective_matrix.inverted()
- viewvec = rv3d.view_matrix.inverted()[2].to_3d().normalized()
- perspinv_x, perspinv_y = rv3d.perspective_matrix.inverted().to_3x3()[0:2]
- return ((perspinv_x * dx + perspinv_y * dy) - viewvec).normalized()
+ out = Vector(((2.0 * coord[0] / region.width) - 1.0,
+ (2.0 * coord[1] / region.height) - 1.0,
+ -0.5
+ ))
+
+ w = (out[0] * persinv[0][3]) + (out[1] * persinv[1][3]) + (out[2] * persinv[2][3]) + persinv[3][3]
+
+ return ((out * persinv) / w) - rv3d.view_matrix.inverted()[3].xyz
+ else:
+ return rv3d.view_matrix.inverted()[2].xyz.normalized()
def region_2d_to_location_3d(region, rv3d, coord, depth_location):
@@ -62,10 +69,28 @@ def region_2d_to_location_3d(region, rv3d, coord, depth_location):
:return: normalized 3d vector.
:rtype: :class:`Vector`
"""
+ from mathutils import Vector
from mathutils.geometry import intersect_point_line
- origin_start = rv3d.view_matrix.inverted()[3].to_3d()
- origin_end = origin_start + region_2d_to_vector_3d(region, rv3d, coord)
- return intersect_point_line(depth_location, origin_start, origin_end)[0]
+
+ persmat = rv3d.perspective_matrix.copy()
+ coord_vec = region_2d_to_vector_3d(region, rv3d, coord)
+ depth_location = Vector(depth_location)
+
+ if rv3d.is_perspective:
+ from mathutils.geometry import intersect_line_plane
+
+ origin_start = rv3d.view_matrix.inverted()[3].to_3d()
+ origin_end = origin_start + coord_vec
+ view_vec = rv3d.view_matrix.inverted()[2]
+ return intersect_line_plane(origin_start, origin_end, depth_location, view_vec, 1)
+ else:
+ dx = (2.0 * coord[0] / region.width) - 1.0
+ dy = (2.0 * coord[1] / region.height) - 1.0
+ persinv = persmat.inverted()
+ viewinv = rv3d.view_matrix.inverted()
+ origin_start = (persinv[0].xyz * dx) + (persinv[1].xyz * dy) + viewinv[3].xyz
+ origin_end = origin_start + coord_vec
+ return intersect_point_line(depth_location, origin_start, origin_end)[0]
def location_3d_to_region_2d(region, rv3d, coord):
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index 5c565fbd300..2f933fb5771 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -102,7 +102,8 @@ def register():
('Render', "Render", ""),
('Rigging', "Rigging", ""),
('Text Editor', "Text Editor", ""),
- ('System', "System", "")
+ ('System', "System", ""),
+ ('Other', "Other", ""),
],
name="Category",
description="Filter add-ons by category",
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index bf396e98c79..cad5369f440 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -752,7 +752,7 @@ class USERPREF_PT_file(bpy.types.Panel):
from bl_ui.space_userpref_keymap import InputKeyMapPanel
-class USERPREF_PT_input(InputKeyMapPanel):
+class USERPREF_PT_input(bpy.types.Panel, InputKeyMapPanel):
bl_space_type = 'USER_PREFERENCES'
bl_label = "Input"
diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py
index 378fe231091..982e19e6234 100644
--- a/release/scripts/startup/bl_ui/space_userpref_keymap.py
+++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py
@@ -138,7 +138,7 @@ class USERPREF_MT_keyconfigs(bpy.types.Menu):
bpy.types.Menu.draw_preset(self, context)
-class InputKeyMapPanel(bpy.types.Panel):
+class InputKeyMapPanel:
bl_space_type = 'USER_PREFERENCES'
bl_label = "Input"
bl_region_type = 'WINDOW'
diff --git a/source/blender/blenkernel/BKE_icons.h b/source/blender/blenkernel/BKE_icons.h
index 5404402718d..3c12a5d615d 100644
--- a/source/blender/blenkernel/BKE_icons.h
+++ b/source/blender/blenkernel/BKE_icons.h
@@ -52,6 +52,7 @@ struct Icon
typedef struct Icon Icon;
struct PreviewImage;
+struct ID;
void BKE_icons_init(int first_dyn_id);
@@ -74,11 +75,14 @@ void BKE_icon_changed(int icon_id);
/* free all icons */
void BKE_icons_free(void);
+/* free the preview image for use in list */
+void BKE_previewimg_freefunc(void *link);
+
/* free the preview image */
void BKE_previewimg_free(struct PreviewImage **prv);
/* free the preview image belonging to the id */
-void BKE_previewimg_free_id(ID *id);
+void BKE_previewimg_free_id(struct ID *id);
/* create a new preview image */
struct PreviewImage* BKE_previewimg_create(void) ;
@@ -87,6 +91,6 @@ struct PreviewImage* BKE_previewimg_create(void) ;
struct PreviewImage* BKE_previewimg_copy(struct PreviewImage *prv);
/* retrieve existing or create new preview image */
-PreviewImage* BKE_previewimg_get(ID *id);
+struct PreviewImage* BKE_previewimg_get(struct ID *id);
#endif /* BKE_ICONS_H */
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 3a98f892bd8..a6b5c04b5c3 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -83,6 +83,7 @@ float dof_camera(struct Object *ob);
void *add_lamp(const char *name);
struct Lamp *copy_lamp(struct Lamp *la);
+struct Lamp *localize_lamp(struct Lamp *la);
void make_local_lamp(struct Lamp *la);
void free_camera(struct Camera *ca);
void free_lamp(struct Lamp *la);
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 56b0cd63e01..bc443b4a3a6 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -246,6 +246,9 @@ void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene);
void BKE_screen_view3d_scene_sync(struct bScreen *sc);
void BKE_screen_view3d_main_sync(ListBase *screen_lb, struct Scene *scene);
+/* zoom factor conversion */
+float BKE_screen_view3d_zoom_to_fac(float camzoom);
+float BKE_screen_view3d_zoom_from_fac(float zoomfac);
/* screen */
void free_screen(struct bScreen *sc);
diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h
index 3394d5b7bf6..9ba74eaf2fc 100644
--- a/source/blender/blenkernel/BKE_subsurf.h
+++ b/source/blender/blenkernel/BKE_subsurf.h
@@ -58,7 +58,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
struct DerivedMesh *dm,
struct SubsurfModifierData *smd,
int useRenderParams, float (*vertCos)[3],
- int isFinalCalc, int editMode);
+ int isFinalCalc, int forEditMode, int inEditMode);
void subsurf_calculate_limit_positions(struct Mesh *me, float (*positions_r)[3]);
diff --git a/source/blender/blenkernel/BKE_world.h b/source/blender/blenkernel/BKE_world.h
index 30780b87085..6c8d1ba7945 100644
--- a/source/blender/blenkernel/BKE_world.h
+++ b/source/blender/blenkernel/BKE_world.h
@@ -40,6 +40,7 @@ struct World;
void free_world(struct World *sc);
struct World *add_world(const char *name);
struct World *copy_world(struct World *wrld);
+struct World *localize_world(struct World *wrld);
void make_local_world(struct World *wrld);
#endif
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 5b49d9a9841..77f56058a4f 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -831,7 +831,10 @@ void pose_remove_group (Object *ob)
/* now, remove it from the pose */
BLI_freelinkN(&pose->agroups, grp);
- pose->active_group= 0;
+ pose->active_group--;
+ if(pose->active_group < 0 || pose->agroups.first == NULL) {
+ pose->active_group= 0;
+ }
}
}
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 5b79f07f84d..e794d0f6172 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -191,7 +191,7 @@ static void clean_paths(Main *main)
/* note, this is called on Undo so any slow conversion functions here
* should be avoided or check (mode!='u') */
-static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename)
+static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath)
{
bScreen *curscreen= NULL;
Scene *curscene= NULL;
@@ -295,18 +295,18 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename
if(recover && bfd->filename[0] && G.relbase_valid) {
/* in case of autosave or quit.blend, use original filename instead
* use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */
- filename= bfd->filename;
+ filepath= bfd->filename;
}
#if 0
else if (!G.relbase_valid) {
/* otherwise, use an empty string as filename, rather than <memory2> */
- filename="";
+ filepath="";
}
#endif
/* these are the same at times, should never copy to the same location */
- if(G.main->name != filename)
- BLI_strncpy(G.main->name, filename, FILE_MAX);
+ if(G.main->name != filepath)
+ BLI_strncpy(G.main->name, filepath, FILE_MAX);
/* baseflags, groups, make depsgraph, etc */
set_scene_bg(G.main, CTX_data_scene(C));
@@ -353,15 +353,15 @@ void BKE_userdef_free(void)
BLI_freelistN(&U.addons);
}
-int BKE_read_file(bContext *C, const char *dir, ReportList *reports)
+int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
{
BlendFileData *bfd;
int retval= BKE_READ_FILE_OK;
- if(strstr(dir, BLENDER_STARTUP_FILE)==NULL) /* dont print user-pref loading */
- printf("read blend: %s\n", dir);
+ if(strstr(filepath, BLENDER_STARTUP_FILE)==NULL) /* dont print user-pref loading */
+ printf("read blend: %s\n", filepath);
- bfd= BLO_read_from_file(dir, reports);
+ bfd= BLO_read_from_file(filepath, reports);
if (bfd) {
if(bfd->user) retval= BKE_READ_FILE_OK_USERPREFS;
@@ -372,10 +372,10 @@ int BKE_read_file(bContext *C, const char *dir, ReportList *reports)
retval= BKE_READ_FILE_FAIL;
}
else
- setup_app_data(C, bfd, dir); // frees BFD
+ setup_app_data(C, bfd, filepath); // frees BFD
}
else
- BKE_reports_prependf(reports, "Loading %s failed: ", dir);
+ BKE_reports_prependf(reports, "Loading %s failed: ", filepath);
return (bfd?retval:BKE_READ_FILE_FAIL);
}
@@ -521,19 +521,19 @@ void BKE_write_undo(bContext *C, const char *name)
/* disk save version */
if(UNDO_DISK) {
static int counter= 0;
- char tstr[FILE_MAXDIR+FILE_MAXFILE];
+ char filepath[FILE_MAXDIR+FILE_MAXFILE];
char numstr[32];
- /* calculate current filename */
+ /* calculate current filepath */
counter++;
counter= counter % U.undosteps;
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
- BLI_make_file_string("/", tstr, btempdir, numstr);
+ BLI_make_file_string("/", filepath, btempdir, numstr);
- success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL, NULL);
+ success= BLO_write_file(CTX_data_main(C), filepath, G.fileflags, NULL, NULL);
- BLI_strncpy(curundo->str, tstr, sizeof(curundo->str));
+ BLI_strncpy(curundo->str, filepath, sizeof(curundo->str));
}
else {
MemFile *prevfile=NULL;
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index b1272ee2d53..d6a9d950015 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -2039,7 +2039,7 @@ float evaluate_fcurve (FCurve *fcu, float evaltime)
* here so that the curve can be sampled correctly
*/
if (fcu->flag & FCURVE_INT_VALUES)
- cvalue= (float)((int)cvalue);
+ cvalue= floorf(cvalue + 0.5f);
/* return evaluated value */
return cvalue;
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index 18eda831c47..9effd25c142 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -132,18 +132,26 @@ struct PreviewImage* BKE_previewimg_create(void)
return prv_img;
}
-void BKE_previewimg_free(PreviewImage **prv)
+void BKE_previewimg_freefunc(void *link)
{
- if(prv && (*prv)) {
+ PreviewImage *prv = (PreviewImage *)link;
+ if (prv) {
int i;
-
+
for (i=0; i<NUM_ICON_SIZES;++i) {
- if ((*prv)->rect[i]) {
- MEM_freeN((*prv)->rect[i]);
- (*prv)->rect[i] = NULL;
+ if (prv->rect[i]) {
+ MEM_freeN(prv->rect[i]);
+ prv->rect[i] = NULL;
}
}
- MEM_freeN((*prv));
+ MEM_freeN(prv);
+ }
+}
+
+void BKE_previewimg_free(PreviewImage **prv)
+{
+ if(prv && (*prv)) {
+ BKE_previewimg_freefunc(*prv);
*prv = NULL;
}
}
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index fd58dc2dfc0..334f018efc9 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -258,9 +258,8 @@ Material *localize_material(Material *ma)
man->preview = NULL;
- if(ma->nodetree) {
+ if(ma->nodetree)
man->nodetree= ntreeLocalize(ma->nodetree);
- }
man->gpumaterial.first= man->gpumaterial.last= NULL;
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index eb92c2f3868..01ef39487d6 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -471,7 +471,7 @@ DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int
return multires_dm_create_from_derived(&mmd, 1, dm, ob, 0, 0);
}
-static DerivedMesh *subsurf_dm_create_local(Object *UNUSED(ob), DerivedMesh *dm, int lvl, int simple, int optimal)
+static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal)
{
SubsurfModifierData smd= {{NULL}};
@@ -482,7 +482,7 @@ static DerivedMesh *subsurf_dm_create_local(Object *UNUSED(ob), DerivedMesh *dm,
if(optimal)
smd.flags |= eSubsurfModifierFlag_ControlEdges;
- return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0);
+ return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0, (ob->mode & OB_MODE_EDIT));
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 74b63a83dce..9b3f8713ff0 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -868,11 +868,32 @@ Lamp *copy_lamp(Lamp *la)
lan->curfalloff = curvemapping_copy(la->curfalloff);
-#if 0 // XXX old animation system
- id_us_plus((ID *)lan->ipo);
-#endif // XXX old animation system
+ if(la->preview)
+ lan->preview = BKE_previewimg_copy(la->preview);
+
+ return lan;
+}
+
+Lamp *localize_lamp(Lamp *la)
+{
+ Lamp *lan;
+ int a;
+
+ lan= copy_libblock(la);
+ BLI_remlink(&G.main->lamp, lan);
+
+ for(a=0; a<MAX_MTEX; a++) {
+ if(lan->mtex[a]) {
+ lan->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_lamp");
+ memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
+ /* free lamp decrements */
+ id_us_plus((ID *)lan->mtex[a]->tex);
+ }
+ }
+
+ lan->curfalloff = curvemapping_copy(la->curfalloff);
- if (la->preview) lan->preview = BKE_previewimg_copy(la->preview);
+ lan->preview= NULL;
return lan;
}
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 63e35408381..50b3e32278a 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -31,6 +31,7 @@
* \ingroup bke
*/
+#include "BLI_winstuff.h"
#include <string.h>
#include <stdio.h>
@@ -416,3 +417,20 @@ void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene)
}
}
+/* magic zoom calculation, no idea what
+ * it signifies, if you find out, tell me! -zr
+ */
+
+/* simple, its magic dude!
+ * well, to be honest, this gives a natural feeling zooming
+ * with multiple keypad presses (ton)
+ */
+float BKE_screen_view3d_zoom_to_fac(float camzoom)
+{
+ return powf(((float)M_SQRT2 + camzoom/50.0f), 2.0f) / 4.0f;
+}
+
+float BKE_screen_view3d_zoom_from_fac(float zoomfac)
+{
+ return ((sqrtf(4.0f * zoomfac) - (float)M_SQRT2) * 50.0f);
+}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index fb72ab676b0..30abb6278a7 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -977,16 +977,22 @@ static float give_stripelem_index(Sequence *seq, float cfra)
int sta = seq->start;
int end = seq->start+seq->len-1;
- if(seq->len == 0) return -1;
+ if (seq->type & SEQ_EFFECT) {
+ end = seq->enddisp;
+ }
+
+ if(end < sta) {
+ return -1;
+ }
if(seq->flag&SEQ_REVERSE_FRAMES) {
/*reverse frame in this sequence */
- if(cfra <= sta) nr= seq->len-1;
+ if(cfra <= sta) nr= end - sta;
else if(cfra >= end) nr= 0;
else nr= end - cfra;
} else {
if(cfra <= sta) nr= 0;
- else if(cfra >= end) nr= seq->len-1;
+ else if(cfra >= end) nr= end - sta;
else nr= cfra - sta;
}
@@ -2036,8 +2042,9 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr
break;
}
case SEQ_EFFECT:
- {
- ibuf = seq_render_effect_strip_impl(context, seq, cfra);
+ {
+ ibuf = seq_render_effect_strip_impl(
+ context, seq, seq->start + nr);
break;
}
case SEQ_IMAGE:
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 653e7612a17..fcdf30be992 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -564,7 +564,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
ssmd.subdivType = ME_CC_SUBSURF; //catmull clark
ssmd.levels = smd->subsurfLevels; //levels
- ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, FALSE, NULL, 0, 0);
+ ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, FALSE, NULL, 0, 0, (ob->mode & OB_MODE_EDIT));
if(ss_mesh)
{
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index ae6ea6f4115..652b667499b 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -3025,7 +3025,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
struct DerivedMesh *dm,
struct SubsurfModifierData *smd,
int useRenderParams, float (*vertCos)[3],
- int isFinalCalc, int editMode)
+ int isFinalCalc, int forEditMode, int inEditMode)
{
int useSimple = smd->subdivType == ME_SIMPLE_SUBSURF;
int useAging = smd->flags & eSubsurfModifierFlag_DebugIncr;
@@ -3033,7 +3033,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
int drawInteriorEdges = !(smd->flags & eSubsurfModifierFlag_ControlEdges);
CCGDerivedMesh *result = NULL;
- if(editMode) {
+ if(forEditMode) {
int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels;
smd->emCache = _getSubSurf(smd->emCache, levels, useAging, 0,
@@ -3064,7 +3064,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
int useAging = smd->flags & eSubsurfModifierFlag_DebugIncr;
int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels;
CCGSubSurf *ss;
-
+
/* It is quite possible there is a much better place to do this. It
* depends a bit on how rigourously we expect this function to never
* be called in editmode. In semi-theory we could share a single
@@ -3072,8 +3072,11 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
* the same so we would need some way of converting them. Its probably
* not worth the effort. But then why am I even writing this long
* comment that no one will read? Hmmm. - zr
+ *
+ * Addendum: we can't really ensure that this is never called in edit
+ * mode, so now we have a parameter to verify it. - brecht
*/
- if(smd->emCache) {
+ if(!inEditMode && smd->emCache) {
ccgSubSurf_free(smd->emCache);
smd->emCache = NULL;
}
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 7a76e61c17b..d413177873f 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -43,6 +43,7 @@
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_world.h"
@@ -117,17 +118,36 @@ World *copy_world(World *wrld)
for(a=0; a<MAX_MTEX; a++) {
if(wrld->mtex[a]) {
- wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
+ wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "copy_world");
memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
id_us_plus((ID *)wrldn->mtex[a]->tex);
}
}
- if (wrld->preview) wrldn->preview = BKE_previewimg_copy(wrld->preview);
+ if(wrld->preview)
+ wrldn->preview = BKE_previewimg_copy(wrld->preview);
-#if 0 // XXX old animation system
- id_us_plus((ID *)wrldn->ipo);
-#endif // XXX old animation system
+ return wrldn;
+}
+
+World *localize_world(World *wrld)
+{
+ World *wrldn;
+ int a;
+
+ wrldn= copy_libblock(wrld);
+ BLI_remlink(&G.main->world, wrldn);
+
+ for(a=0; a<MAX_MTEX; a++) {
+ if(wrld->mtex[a]) {
+ wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_world");
+ memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
+ /* free world decrements */
+ id_us_plus((ID *)wrldn->mtex[a]->tex);
+ }
+ }
+
+ wrldn->preview= NULL;
return wrldn;
}
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 16684b0d84a..6912be63daa 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -98,6 +98,18 @@ int isect_line_line_strict_v3(const float v1[3], const float v2[3],
int isect_ray_plane_v3(float p1[3], float d[3], float v0[3],
float v1[3], float v2[3], float *lambda, int clip);
+/**
+ * Intersect line/plane, optionally treat line as directional (like a ray) with the no_flip argument.
+ * @param out The intersection point.
+ * @param l1 The first point of the line.
+ * @param l2 The second point of the line.
+ * @param plane_co A point on the plane to intersect with.
+ * @param plane_no The direction of the plane (does not need to be normalized).
+ * @param no_flip When true, the intersection point will always be from l1 to l2, even if this is not on the plane.
+ */
+int isect_line_plane_v3(float out[3], const float l1[3], const float l2[3],
+ const float plane_co[3], const float plane_no[3], const short no_flip);
+
/* line/ray triangle */
int isect_line_tri_v3(const float p1[3], const float p2[3],
const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2]);
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 939c4348461..d8719f399ae 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -84,7 +84,7 @@ void mul_v3_m4v3(float r[3], float M[4][4], float v[3]);
void mul_mat3_m4_v3(float M[4][4], float r[3]);
void mul_m4_v4(float M[4][4], float r[4]);
void mul_v4_m4v4(float r[4], float M[4][4], float v[4]);
-void mul_project_m4_v4(float M[4][4], float r[3]);
+void mul_project_m4_v3(float M[4][4], float vec[3]);
void mul_m3_v3(float M[3][3], float r[3]);
void mul_v3_m3v3(float r[3], float M[3][3], float a[3]);
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 2a2583b1cc2..c81ab01e468 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -112,7 +112,7 @@
#define VECADD(v1,v2,v3) {*(v1)= *(v2) + *(v3); *(v1+1)= *(v2+1) + *(v3+1); *(v1+2)= *(v2+2) + *(v3+2);}
#define VECSUB(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);}
-#define VECSUB2D(v1,v2,v3, fac) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1);}
+#define VECSUB2D(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1);}
#define VECINTERP(v1,v2,v3, fac) {*(v1) = *(v2) + (*(v3)-*(v2))*(fac); *(v1+1) = *(v2+1) + (*(v3+1)-*(v2+1))*(fac); *(v1+2) = *(v2+2) + (*(v3+2)-*(v2+2))*(fac);}
#define VECADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac);}
#define VECSUBFAC(v1,v2,v3,fac) {*(v1)= *(v2) - *(v3)*(fac); *(v1+1)= *(v2+1) - *(v3+1)*(fac); *(v1+2)= *(v2+2) - *(v3+2)*(fac);}
diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c
index a56b1392b69..654ade8955f 100644
--- a/source/blender/blenlib/intern/bpath.c
+++ b/source/blender/blenlib/intern/bpath.c
@@ -68,21 +68,16 @@
#include "BKE_utildefines.h"
#include "BKE_report.h"
-//XXX #include "BIF_screen.h" /* only for wait cursor */
-//
-/* for sequence */
-//XXX #include "BSE_sequence.h"
-//XXX define below from BSE_sequence.h - otherwise potentially odd behaviour
-
-
-typedef struct BPathIteratorSeqData {
+typedef struct BPathIteratorSeqData
+{
int totseq;
int seq;
- struct Sequence **seqar; /* Sequence */
- struct Scene *scene; /* Current scene */
+ struct Sequence **seqar; /* Sequence */
+ struct Scene *scene; /* Current scene */
} BPathIteratorSeqData;
-typedef struct BPathIterator {
+typedef struct BPathIterator
+{
char* _path; /* never access directly, use BLI_bpathIterator_getPath */
const char* _lib;
const char* _name;
@@ -94,7 +89,7 @@ typedef struct BPathIterator {
void (*setpath_callback)(struct BPathIterator *, const char *);
void (*getpath_callback)(struct BPathIterator *, char *);
- const char* base_path; /* base path, the directry the blend file is in - normally bmain->name */
+ const char* base_path; /* base path, the directory the blend file is in - normally bmain->name */
Main *bmain;
@@ -116,7 +111,7 @@ enum BPathTypes {
BPATH_SEQ,
BPATH_CDATA,
- BPATH_DONE
+ BPATH_DONE
};
void BLI_bpathIterator_init(struct BPathIterator **bpi_pt, Main *bmain, const char *basedir, const int flag)
@@ -128,10 +123,10 @@ void BLI_bpathIterator_init(struct BPathIterator **bpi_pt, Main *bmain, const ch
bpi->type= BPATH_IMAGE;
bpi->data= NULL;
-
+
bpi->getpath_callback= NULL;
bpi->setpath_callback= NULL;
-
+
/* Sequencer specific */
bpi->seqdata.totseq= 0;
bpi->seqdata.seq= 0;
@@ -147,62 +142,75 @@ void BLI_bpathIterator_init(struct BPathIterator **bpi_pt, Main *bmain, const ch
}
#if 0
-static void BLI_bpathIterator_alloc(struct BPathIterator **bpi) {
+static void BLI_bpathIterator_alloc(struct BPathIterator **bpi)
+{
*bpi= MEM_mallocN(sizeof(BPathIterator), "BLI_bpathIterator_alloc");
}
#endif
-void BLI_bpathIterator_free(struct BPathIterator *bpi) {
+void BLI_bpathIterator_free(struct BPathIterator *bpi)
+{
if (bpi->seqdata.seqar)
MEM_freeN((void *)bpi->seqdata.seqar);
bpi->seqdata.seqar= NULL;
bpi->seqdata.scene= NULL;
-
+
MEM_freeN(bpi);
}
-void BLI_bpathIterator_getPath(struct BPathIterator *bpi, char *path) {
+void BLI_bpathIterator_getPath(struct BPathIterator *bpi, char *path)
+{
if (bpi->getpath_callback) {
bpi->getpath_callback(bpi, path);
- } else {
+ }
+ else {
strcpy(path, bpi->_path); /* warning, we assume 'path' are long enough */
}
}
-void BLI_bpathIterator_setPath(struct BPathIterator *bpi, const char *path) {
+void BLI_bpathIterator_setPath(struct BPathIterator *bpi, const char *path)
+{
if (bpi->setpath_callback) {
bpi->setpath_callback(bpi, path);
- } else {
+ }
+ else {
strcpy(bpi->_path, path); /* warning, we assume 'path' are long enough */
}
}
-void BLI_bpathIterator_getPathExpanded(struct BPathIterator *bpi, char *path_expanded) {
+void BLI_bpathIterator_getPathExpanded(struct BPathIterator *bpi, char *path_expanded)
+{
const char *libpath;
-
+
BLI_bpathIterator_getPath(bpi, path_expanded);
libpath= BLI_bpathIterator_getLib(bpi);
-
+
if (libpath) { /* check the files location relative to its library path */
BLI_path_abs(path_expanded, libpath);
- } else { /* local data, use the blend files path */
+ }
+ else { /* local data, use the blend files path */
BLI_path_abs(path_expanded, bpi->base_path);
}
BLI_cleanup_file(NULL, path_expanded);
}
-const char* BLI_bpathIterator_getLib(struct BPathIterator *bpi) {
+const char* BLI_bpathIterator_getLib(struct BPathIterator *bpi)
+{
return bpi->_lib;
}
-const char* BLI_bpathIterator_getName(struct BPathIterator *bpi) {
+const char* BLI_bpathIterator_getName(struct BPathIterator *bpi)
+{
return bpi->_name;
}
-int BLI_bpathIterator_getType(struct BPathIterator *bpi) {
+int BLI_bpathIterator_getType(struct BPathIterator *bpi)
+{
return bpi->type;
}
-unsigned int BLI_bpathIterator_getPathMaxLen(struct BPathIterator *bpi) {
+unsigned int BLI_bpathIterator_getPathMaxLen(struct BPathIterator *bpi)
+{
return bpi->len;
}
-const char* BLI_bpathIterator_getBasePath(struct BPathIterator *bpi) {
+const char* BLI_bpathIterator_getBasePath(struct BPathIterator *bpi)
+{
return bpi->base_path;
}
@@ -211,10 +219,10 @@ static struct Image *ima_stepdata__internal(struct Image *ima, const int step_ne
{
if (ima==NULL)
return NULL;
-
+
if (step_next)
ima= ima->id.next;
-
+
while (ima) {
if (ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
if(ima->packedfile==NULL || (flag & BPATH_USE_PACKED)) {
@@ -223,7 +231,7 @@ static struct Image *ima_stepdata__internal(struct Image *ima, const int step_ne
}
/* image is not a image with a path, skip it */
ima= ima->id.next;
- }
+ }
return ima;
}
@@ -240,7 +248,7 @@ static struct Tex *tex_stepdata__internal(struct Tex *tex, const int step_next,
break;
/* image is not a image with a path, skip it */
tex= tex->id.next;
- }
+ }
return tex;
}
@@ -257,7 +265,7 @@ static struct Text *text_stepdata__internal(struct Text *text, const int step_ne
break;
/* image is not a image with a path, skip it */
text= text->id.next;
- }
+ }
return text;
}
@@ -265,20 +273,20 @@ static struct VFont *vf_stepdata__internal(struct VFont *vf, const int step_next
{
if (vf==NULL)
return NULL;
-
+
if (step_next)
vf= vf->id.next;
-
+
while (vf) {
if (strcmp(vf->name, FO_BUILTIN_NAME)!=0) {
if(vf->packedfile==NULL || (flag & BPATH_USE_PACKED)) {
break;
}
}
-
+
/* font with no path, skip it */
vf= vf->id.next;
- }
+ }
return vf;
}
@@ -286,10 +294,10 @@ static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next,
{
if (snd==NULL)
return NULL;
-
+
if (step_next)
snd= snd->id.next;
-
+
while (snd) {
if(snd->packedfile==NULL || (flag & BPATH_USE_PACKED)) {
break;
@@ -297,7 +305,7 @@ static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next,
/* font with no path, skip it */
snd= snd->id.next;
- }
+ }
return snd;
}
@@ -305,16 +313,16 @@ static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int st
{
Editing *ed;
Sequence *seq;
-
+
/* Initializing */
if (bpi->seqdata.scene==NULL) {
bpi->seqdata.scene= bpi->bmain->scene.first;
}
-
+
if (step_next) {
bpi->seqdata.seq++;
}
-
+
while (bpi->seqdata.scene) {
ed= seq_give_editing(bpi->seqdata.scene, 0);
if (ed) {
@@ -323,10 +331,11 @@ static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int st
seq_array(ed, &bpi->seqdata.seqar, &bpi->seqdata.totseq, 0);
bpi->seqdata.seq= 0;
}
-
+
if (bpi->seqdata.seq >= bpi->seqdata.totseq) {
seq= NULL;
- } else {
+ }
+ else {
seq= bpi->seqdata.seqar[bpi->seqdata.seq];
while (!SEQ_HAS_PATH(seq) && seq->plugin==NULL) {
bpi->seqdata.seq++;
@@ -339,7 +348,8 @@ static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int st
}
if (seq) {
return seq;
- } else {
+ }
+ else {
/* keep looking through the next scene, reallocate seq array */
if (bpi->seqdata.seqar) {
MEM_freeN((void *)bpi->seqdata.seqar);
@@ -347,19 +357,21 @@ static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int st
}
bpi->seqdata.scene= bpi->seqdata.scene->id.next;
}
- } else {
+ }
+ else {
/* no seq data in this scene, next */
bpi->seqdata.scene= bpi->seqdata.scene->id.next;
}
}
-
+
return NULL;
}
-static void seq_getpath(struct BPathIterator *bpi, char *path) {
+static void seq_getpath(struct BPathIterator *bpi, char *path)
+{
Sequence *seq= (Sequence *)bpi->data;
-
+
path[0]= '\0'; /* incase we cant get the path */
if (seq==NULL) return;
if (SEQ_HAS_PATH(seq)) {
@@ -369,7 +381,7 @@ static void seq_getpath(struct BPathIterator *bpi, char *path) {
if (seq->strip->stripdata) { /* should always be true! */
/* Using the first image is weak for image sequences */
strcat(path, seq->strip->stripdata->name);
- }
+ }
}
else {
/* simple case */
@@ -381,10 +393,11 @@ static void seq_getpath(struct BPathIterator *bpi, char *path) {
}
}
-static void seq_setpath(struct BPathIterator *bpi, const char *path) {
+static void seq_setpath(struct BPathIterator *bpi, const char *path)
+{
Sequence *seq= (Sequence *)bpi->data;
- if (seq==NULL) return;
-
+ if (seq==NULL) return;
+
if (SEQ_HAS_PATH(seq)) {
if (ELEM3(seq->type, SEQ_IMAGE, SEQ_MOVIE, SEQ_SOUND)) {
BLI_split_dirfile(path, seq->strip->dir, seq->strip->stripdata->name);
@@ -399,7 +412,8 @@ static void seq_setpath(struct BPathIterator *bpi, const char *path) {
}
}
-static void text_getpath(struct BPathIterator *bpi, char *path) {
+static void text_getpath(struct BPathIterator *bpi, char *path)
+{
Text *text= (Text *)bpi->data;
path[0]= '\0'; /* incase we cant get the path */
if(text->name) {
@@ -407,9 +421,10 @@ static void text_getpath(struct BPathIterator *bpi, char *path) {
}
}
-static void text_setpath(struct BPathIterator *bpi, const char *path) {
+static void text_setpath(struct BPathIterator *bpi, const char *path)
+{
Text *text= (Text *)bpi->data;
- if (text==NULL) return;
+ if (text==NULL) return;
if(text->name) {
MEM_freeN(text->name);
@@ -418,27 +433,29 @@ static void text_setpath(struct BPathIterator *bpi, const char *path) {
text->name= BLI_strdup(path);
}
-static struct Mesh *cdata_stepdata__internal(struct Mesh *me, int step_next) {
+static struct Mesh *cdata_stepdata__internal(struct Mesh *me, int step_next)
+{
if (me==NULL)
return NULL;
-
+
if (step_next)
me= me->id.next;
-
+
while (me) {
if (me->fdata.external) {
break;
}
-
+
me= me->id.next;
- }
+ }
return me;
}
-static void bpi_type_step__internal(struct BPathIterator *bpi) {
+static void bpi_type_step__internal(struct BPathIterator *bpi)
+{
bpi->type++; /* advance to the next type */
bpi->data= NULL;
-
+
switch (bpi->type) {
case BPATH_SEQ:
bpi->getpath_callback= seq_getpath;
@@ -455,27 +472,29 @@ static void bpi_type_step__internal(struct BPathIterator *bpi) {
}
}
-void BLI_bpathIterator_step(struct BPathIterator *bpi) {
+void BLI_bpathIterator_step(struct BPathIterator *bpi)
+{
while (bpi->type != BPATH_DONE) {
-
+
if ((bpi->type) == BPATH_IMAGE) {
/*if (bpi->data) bpi->data= ((ID *)bpi->data)->next;*/
if (bpi->data) bpi->data= ima_stepdata__internal((Image *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
else bpi->data= ima_stepdata__internal(bpi->bmain->image.first, 0, bpi->flag);
-
+
if (bpi->data) {
/* get the path info from this datatype */
Image *ima= (Image *)bpi->data;
-
+
bpi->_lib= ima->id.lib ? ima->id.lib->filepath : NULL;
bpi->_path= ima->name;
bpi->_name= ima->id.name+2;
bpi->len= sizeof(ima->name);
-
+
/* we are done, advancing to the next item, this type worked fine */
break;
- } else {
+ }
+ else {
bpi_type_step__internal(bpi);
}
}
@@ -502,7 +521,8 @@ void BLI_bpathIterator_step(struct BPathIterator *bpi) {
/* we are done, advancing to the next item, this type worked fine */
break;
- } else {
+ }
+ else {
bpi_type_step__internal(bpi);
}
}
@@ -524,11 +544,11 @@ void BLI_bpathIterator_step(struct BPathIterator *bpi) {
/* we are done, advancing to the next item, this type worked fine */
break;
- } else {
+ }
+ else {
bpi_type_step__internal(bpi);
}
}
-
else if ((bpi->type) == BPATH_SOUND) {
if (bpi->data) bpi->data= snd_stepdata__internal((bSound *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
else bpi->data= snd_stepdata__internal(bpi->bmain->sound.first, 0, bpi->flag);
@@ -544,16 +564,16 @@ void BLI_bpathIterator_step(struct BPathIterator *bpi) {
/* we are done, advancing to the next item, this type worked fine */
break;
- } else {
+ }
+ else {
bpi_type_step__internal(bpi);
}
-
-
- } else if ((bpi->type) == BPATH_FONT) {
-
+ }
+ else if ((bpi->type) == BPATH_FONT) {
+
if (bpi->data) bpi->data= vf_stepdata__internal((VFont *)bpi->data, 1, bpi->flag);
else bpi->data= vf_stepdata__internal(bpi->bmain->vfont.first, 0, bpi->flag);
-
+
if (bpi->data) {
/* get the path info from this datatype */
VFont *vf= (VFont *)bpi->data;
@@ -565,29 +585,33 @@ void BLI_bpathIterator_step(struct BPathIterator *bpi) {
/* we are done, advancing to the next item, this type worked fine */
break;
- } else {
+ }
+ else {
bpi_type_step__internal(bpi);
}
- } else if ((bpi->type) == BPATH_LIB) {
+ }
+ else if ((bpi->type) == BPATH_LIB) {
if (bpi->data) bpi->data= ((ID *)bpi->data)->next;
else bpi->data= bpi->bmain->library.first;
-
+
if (bpi->data) {
/* get the path info from this datatype */
Library *lib= (Library *)bpi->data;
-
+
bpi->_lib= NULL;
bpi->_path= lib->name;
bpi->_name= NULL;
bpi->len= sizeof(lib->name);
-
+
/* we are done, advancing to the next item, this type worked fine */
break;
- } else {
+ }
+ else {
bpi_type_step__internal(bpi);
}
- } else if ((bpi->type) == BPATH_SEQ) {
+ }
+ else if ((bpi->type) == BPATH_SEQ) {
if (bpi->data) bpi->data= seq_stepdata__internal( bpi, 1 );
else bpi->data= seq_stepdata__internal( bpi, 0 );
if (bpi->data) {
@@ -596,10 +620,12 @@ void BLI_bpathIterator_step(struct BPathIterator *bpi) {
bpi->_name= seq->name+2;
bpi->len= seq->plugin ? sizeof(seq->plugin->name) : sizeof(seq->strip->dir) + sizeof(seq->strip->stripdata->name);
break;
- } else {
+ }
+ else {
bpi_type_step__internal(bpi);
}
- } else if ((bpi->type) == BPATH_CDATA) {
+ }
+ else if ((bpi->type) == BPATH_CDATA) {
if (bpi->data) bpi->data= cdata_stepdata__internal( bpi->data, 1 );
else bpi->data= cdata_stepdata__internal( bpi->bmain->mesh.first, 0 );
@@ -610,7 +636,8 @@ void BLI_bpathIterator_step(struct BPathIterator *bpi) {
bpi->_name= me->id.name+2;
bpi->len= sizeof(me->fdata.external->filename);
break;
- } else {
+ }
+ else {
bpi_type_step__internal(bpi);
}
}
@@ -627,7 +654,7 @@ static void bpath_as_report(struct BPathIterator *bpi, const char *message, Repo
const char *prefix;
const char *name;
char path_expanded[FILE_MAXDIR*2];
-
+
if(reports==NULL)
return;
@@ -660,7 +687,7 @@ static void bpath_as_report(struct BPathIterator *bpi, const char *message, Repo
prefix= "Unknown";
break;
}
-
+
name= BLI_bpathIterator_getName(bpi);
BLI_bpathIterator_getPathExpanded(bpi, path_expanded);
@@ -674,14 +701,14 @@ static void bpath_as_report(struct BPathIterator *bpi, const char *message, Repo
/* high level function */
void checkMissingFiles(Main *bmain, ReportList *reports) {
struct BPathIterator *bpi;
-
+
/* be sure there is low chance of the path being too short */
- char filepath_expanded[FILE_MAXDIR*2];
-
+ char filepath_expanded[FILE_MAXDIR*2];
+
BLI_bpathIterator_init(&bpi, bmain, bmain->name, 0);
while (!BLI_bpathIterator_isDone(bpi)) {
BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
-
+
if (!BLI_exists(filepath_expanded))
bpath_as_report(bpi, "file not found", reports);
@@ -696,33 +723,41 @@ void makeFilesRelative(Main *bmain, const char *basedir, ReportList *reports) {
struct BPathIterator *bpi;
char filepath[FILE_MAX];
const char *libpath;
-
+
/* be sure there is low chance of the path being too short */
char filepath_relative[(FILE_MAXDIR * 2) + FILE_MAXFILE];
-
+
+ if(basedir[0] == '\0') {
+ printf("makeFilesRelative: basedir='', this is a bug\n");
+ return;
+ }
+
BLI_bpathIterator_init(&bpi, bmain, basedir, 0);
while (!BLI_bpathIterator_isDone(bpi)) {
BLI_bpathIterator_getPath(bpi, filepath);
libpath= BLI_bpathIterator_getLib(bpi);
-
+
if(strncmp(filepath, "//", 2)) {
if (libpath) { /* cant make relative if we are library - TODO, LOG THIS */
linked++;
- } else { /* local data, use the blend files path */
+ }
+ else { /* local data, use the blend files path */
BLI_strncpy(filepath_relative, filepath, sizeof(filepath_relative));
/* Important BLI_cleanup_dir runs before the path is made relative
- * because it wont work for paths that start with "//../" */
+ * because it wont work for paths that start with "//../" */
BLI_cleanup_file(bpi->base_path, filepath_relative); /* fix any /foo/../foo/ */
BLI_path_rel(filepath_relative, bpi->base_path);
/* be safe and check the length */
if (BLI_bpathIterator_getPathMaxLen(bpi) <= strlen(filepath_relative)) {
bpath_as_report(bpi, "couldn't make path relative (too long)", reports);
failed++;
- } else {
+ }
+ else {
if(strncmp(filepath_relative, "//", 2)==0) {
BLI_bpathIterator_setPath(bpi, filepath_relative);
changed++;
- } else {
+ }
+ else {
bpath_as_report(bpi, "couldn't make path relative", reports);
failed++;
}
@@ -747,30 +782,38 @@ void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports)
struct BPathIterator *bpi;
char filepath[FILE_MAX];
const char *libpath;
-
+
/* be sure there is low chance of the path being too short */
char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE];
-
+
+ if(basedir[0] == '\0') {
+ printf("makeFilesAbsolute: basedir='', this is a bug\n");
+ return;
+ }
+
BLI_bpathIterator_init(&bpi, bmain, basedir, 0);
while (!BLI_bpathIterator_isDone(bpi)) {
BLI_bpathIterator_getPath(bpi, filepath);
libpath= BLI_bpathIterator_getLib(bpi);
-
+
if(strncmp(filepath, "//", 2)==0) {
if (libpath) { /* cant make absolute if we are library - TODO, LOG THIS */
linked++;
- } else { /* get the expanded path and check it is relative or too long */
+ }
+ else { /* get the expanded path and check it is relative or too long */
BLI_bpathIterator_getPathExpanded(bpi, filepath_absolute);
BLI_cleanup_file(bpi->base_path, filepath_absolute); /* fix any /foo/../foo/ */
/* to be safe, check the length */
if (BLI_bpathIterator_getPathMaxLen(bpi) <= strlen(filepath_absolute)) {
bpath_as_report(bpi, "couldn't make absolute (too long)", reports);
failed++;
- } else {
+ }
+ else {
if(strncmp(filepath_absolute, "//", 2)) {
BLI_bpathIterator_setPath(bpi, filepath_absolute);
changed++;
- } else {
+ }
+ else {
bpath_as_report(bpi, "couldn't make absolute", reports);
failed++;
}
@@ -801,25 +844,25 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char
struct stat status;
char path[FILE_MAX];
int size;
-
+
dir= opendir(dirname);
-
+
if (dir==NULL)
return 0;
-
+
if (*filesize == -1)
*filesize= 0; /* dir opened fine */
-
+
while ((de= readdir(dir)) != NULL) {
-
+
if (strcmp(".", de->d_name)==0 || strcmp("..", de->d_name)==0)
continue;
-
+
BLI_join_dirfile(path, sizeof(path), dirname, de->d_name);
-
+
if (stat(path, &status) != 0)
continue; /* cant stat, dont bother with this file, could print debug info here */
-
+
if (S_ISREG(status.st_mode)) { /* is file */
if (strncmp(filename, de->d_name, FILE_MAX)==0) { /* name matches */
/* open the file to read its size */
@@ -829,7 +872,8 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char
BLI_strncpy(filename_new, path, FILE_MAX);
}
}
- } else if (S_ISDIR(status.st_mode)) { /* is subdir */
+ }
+ else if (S_ISDIR(status.st_mode)) { /* is subdir */
if (*recur_depth <= MAX_RECUR) {
(*recur_depth)++;
findFileRecursive(filename_new, path, filename, filesize, recur_depth);
@@ -844,54 +888,55 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char
/* high level function - call from fileselector */
void findMissingFiles(Main *bmain, const char *str) {
struct BPathIterator *bpi;
-
+
/* be sure there is low chance of the path being too short */
- char filepath_expanded[FILE_MAXDIR*2];
+ char filepath_expanded[FILE_MAXDIR*2];
char filepath[FILE_MAX];
const char *libpath;
int filesize, recur_depth;
-
+
char dirname[FILE_MAX], filename_new[FILE_MAX];
-
+
//XXX waitcursor( 1 );
-
+
BLI_split_dirfile(str, dirname, NULL);
-
+
BLI_bpathIterator_init(&bpi, bmain, bmain->name, 0);
-
+
while (!BLI_bpathIterator_isDone(bpi)) {
BLI_bpathIterator_getPath(bpi, filepath);
libpath= BLI_bpathIterator_getLib(bpi);
-
+
/* Check if esc was pressed because searching files can be slow */
/*XXX if (blender_test_break()) {
break;
}*/
-
+
if (libpath==NULL) {
-
+
BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
-
+
if (!BLI_exists(filepath_expanded)) {
/* can the dir be opened? */
filesize= -1;
recur_depth= 0;
-
+
findFileRecursive(filename_new, dirname, BLI_path_basename(filepath), &filesize, &recur_depth);
if (filesize == -1) { /* could not open dir */
printf("Could not open dir \"%s\"\n", dirname);
return;
}
-
+
if (filesize > 0) {
-
- if (BLI_bpathIterator_getPathMaxLen(bpi) < strlen(filename_new)) {
+
+ if (BLI_bpathIterator_getPathMaxLen(bpi) < strlen(filename_new)) {
printf("cannot set path \"%s\" too long!", filename_new);
- } else {
+ }
+ else {
/* copy the found path into the old one */
if (G.relbase_valid)
BLI_path_rel(filename_new, bpi->base_path);
-
+
BLI_bpathIterator_setPath(bpi, filename_new);
}
}
@@ -900,6 +945,6 @@ void findMissingFiles(Main *bmain, const char *str) {
BLI_bpathIterator_step(bpi);
}
BLI_bpathIterator_free(bpi);
-
+
//XXX waitcursor( 0 );
}
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 6df942e8b13..dffa7aa2ca3 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -37,7 +37,7 @@
#include "BLI_memarena.h"
#include "BLI_utildefines.h"
-
+static float lambda_cp_line(const float p[3], const float l1[3], const float l2[3]);
/********************************** Polygons *********************************/
@@ -640,6 +640,48 @@ int isect_ray_tri_threshold_v3(const float p1[3], const float d[3], const float
return 1;
}
+int isect_line_plane_v3(float out[3], const float l1[3], const float l2[3], const float plane_co[3], const float plane_no[3], const short no_flip)
+{
+ float l_vec[3]; /* l1 -> l2 normalized vector */
+ float p_no[3]; /* 'plane_no' normalized */
+ float dot;
+
+ sub_v3_v3v3(l_vec, l2, l1);
+
+ normalize_v3(l_vec);
+ normalize_v3_v3(p_no, plane_no);
+
+ dot= dot_v3v3(l_vec, p_no);
+ if(dot == 0.0f) {
+ return 0;
+ }
+ else {
+ float l1_plane[3]; /* line point aligned with the plane */
+ float dist; /* 'plane_no' aligned distance to the 'plane_co' */
+
+ /* for pradictable flipping since the plane is only used to
+ * define a direction, ignore its flipping and aligned with 'l_vec' */
+ if(dot < 0.0f) {
+ dot= -dot;
+ negate_v3(p_no);
+ }
+
+ add_v3_v3v3(l1_plane, l1, p_no);
+
+ dist = lambda_cp_line(plane_co, l1, l1_plane);
+
+ /* treat line like a ray, when 'no_flip' is set */
+ if(no_flip && dist < 0.0f) {
+ dist= -dist;
+ }
+
+ mul_v3_fl(l_vec, dist / dot);
+
+ add_v3_v3v3(out, l1, l_vec);
+
+ return 1;
+ }
+}
/* Adapted from the paper by Kasper Fauerby */
/* "Improved Collision detection and Response" */
@@ -1075,16 +1117,14 @@ float closest_to_line_v2(float cp[2],const float p[2], const float l1[2], const
return lambda;
}
-#if 0
/* little sister we only need to know lambda */
-static float lambda_cp_line(float p[3], float l1[3], float l2[3])
+static float lambda_cp_line(const float p[3], const float l1[3], const float l2[3])
{
float h[3],u[3];
sub_v3_v3v3(u, l2, l1);
sub_v3_v3v3(h, p, l1);
return(dot_v3v3(u,h)/dot_v3v3(u,u));
}
-#endif
/* Similar to LineIntersectsTriangleUV, except it operates on a quad and in 2d, assumes point is in quad */
void isect_point_quad_uv_v2(const float v0[2], const float v1[2], const float v2[2], const float v3[2], const float pt[2], float *uv)
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 9fde87d734f..5edf6e28d4c 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -340,11 +340,9 @@ void mul_mat3_m4_v3(float mat[][4], float *vec)
vec[2]= x*mat[0][2] + y*mat[1][2] + mat[2][2]*vec[2];
}
-void mul_project_m4_v4(float mat[][4], float *vec)
+void mul_project_m4_v3(float mat[][4], float vec[3])
{
- float w;
-
- w = vec[0]*mat[0][3] + vec[1]*mat[1][3] + vec[2]*mat[2][3] + mat[3][3];
+ const float w= vec[0]*mat[0][3] + vec[1]*mat[1][3] + vec[2]*mat[2][3] + mat[3][3];
mul_m4_v3(mat, vec);
vec[0] /= w;
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 22083eda1c8..6267b819c55 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -49,6 +49,8 @@ struct SpaceFile;
struct SpaceImaSel;
struct UserDef;
struct bContext;
+struct BHead;
+struct FileData;
typedef struct BlendHandle BlendHandle;
@@ -79,12 +81,12 @@ typedef struct BlendFileData {
* returns NULL and sets a report in the list if
* it cannot open the file.
*
- * @param file The path of the file to open.
+ * @param filepath The path of the file to open.
* @param reports If the return value is NULL, errors
* indicating the cause of the failure.
* @return The data of the file.
*/
-BlendFileData* BLO_read_from_file(const char *file, struct ReportList *reports);
+BlendFileData* BLO_read_from_file(const char *filepath, struct ReportList *reports);
/**
* Open a blender file from memory. The function
@@ -209,7 +211,7 @@ int BLO_has_bfile_extension(char *str);
*/
int BLO_is_a_library(const char *path, char *dir, char *group);
-struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, char *dir);
+struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, const char *filepath);
/**
* Link/Append a named datablock from an external blend file.
@@ -217,14 +219,16 @@ struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh
* @param C The context, when NULL instancing object in the scene isnt done.
* @param mainl The main database to link from (not the active one).
* @param bh The blender file handle.
- * @param name The name of the datablock (without the 2 char ID prefix)
+ * @param idname The name of the datablock (without the 2 char ID prefix)
* @param idcode The kind of datablock to link.
* @param flag Options for linking, used for instancing.
* @return Boolean, 0 when the datablock could not be found.
*/
-int BLO_library_append_named_part(const struct bContext *C, struct Main *mainl, BlendHandle** bh, const char *name, int idcode, short flag);
+int BLO_library_append_named_part(const struct bContext *C, struct Main *mainl, BlendHandle** bh, const char *idname, int idcode, short flag);
void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag);
+void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
+
/* deprecated */
#if 1
void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Main *mainvar, struct Scene *scene, struct ReportList *reports);
diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h
index 651928aa6a1..5c41350a463 100644
--- a/source/blender/blenloader/BLO_writefile.h
+++ b/source/blender/blenloader/BLO_writefile.h
@@ -39,7 +39,7 @@ struct MemFile;
struct Main;
struct ReportList;
-extern int BLO_write_file(struct Main *mainvar, char *dir, int write_flags, struct ReportList *reports, int *thumb);
+extern int BLO_write_file(struct Main *mainvar, const char *filepath, int write_flags, struct ReportList *reports, int *thumb);
extern int BLO_write_file_mem(struct Main *mainvar, struct MemFile *compare, struct MemFile *current, int write_flags);
extern int BLO_write_runtime(struct Main *mainvar, const char *file, char *exename, struct ReportList *reports);
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 214f637ea6c..4ce5685ff18 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -148,15 +148,14 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
LinkNode *previews= NULL;
BHead *bhead;
int looking=0;
- int npreviews = 0;
PreviewImage* prv = NULL;
PreviewImage* new_prv = NULL;
int tot= 0;
for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) {
if (bhead->code==ofblocktype) {
- ID *id= (ID*) (bhead+1);
- switch(GS(id->name))
+ char *idname= bhead_id_name(fd, bhead);
+ switch(GS(idname))
{
case ID_MA: /* fall through */
case ID_TE: /* fall through */
@@ -174,31 +173,29 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
} else if (bhead->code==DATA) {
if (looking) {
if (bhead->SDNAnr == DNA_struct_find_nr(fd->filesdna, "PreviewImage") ) {
- prv = (PreviewImage*) (bhead+1);
- npreviews = 0;
- memcpy(new_prv, prv, sizeof(PreviewImage));
- if (prv->rect[0]) {
- unsigned int *rect = NULL;
- // int rectlen = 0;
- new_prv->rect[0] = MEM_callocN(new_prv->w[0]*new_prv->h[0]*sizeof(unsigned int), "prvrect");
- bhead= blo_nextbhead(fd, bhead);
- rect = (unsigned int*)(bhead+1);
- // rectlen = new_prv->w[0]*new_prv->h[0]*sizeof(unsigned int);
- memcpy(new_prv->rect[0], rect, bhead->len);
- } else {
- new_prv->rect[0] = NULL;
- }
-
- if (prv->rect[1]) {
- unsigned int *rect = NULL;
- // int rectlen = 0;
- new_prv->rect[1] = MEM_callocN(new_prv->w[1]*new_prv->h[1]*sizeof(unsigned int), "prvrect");
- bhead= blo_nextbhead(fd, bhead);
- rect = (unsigned int*)(bhead+1);
- // rectlen = new_prv->w[1]*new_prv->h[1]*sizeof(unsigned int);
- memcpy(new_prv->rect[1], rect, bhead->len);
- } else {
- new_prv->rect[1] = NULL;
+ prv = BLO_library_read_struct(fd, bhead, "PreviewImage");
+ if (prv) {
+ memcpy(new_prv, prv, sizeof(PreviewImage));
+ if (prv->rect[0]) {
+ unsigned int *rect = NULL;
+ new_prv->rect[0] = MEM_callocN(new_prv->w[0]*new_prv->h[0]*sizeof(unsigned int), "prvrect");
+ bhead= blo_nextbhead(fd, bhead);
+ rect = (unsigned int*)(bhead+1);
+ memcpy(new_prv->rect[0], rect, bhead->len);
+ } else {
+ new_prv->rect[0] = NULL;
+ }
+
+ if (prv->rect[1]) {
+ unsigned int *rect = NULL;
+ new_prv->rect[1] = MEM_callocN(new_prv->w[1]*new_prv->h[1]*sizeof(unsigned int), "prvrect");
+ bhead= blo_nextbhead(fd, bhead);
+ rect = (unsigned int*)(bhead+1);
+ memcpy(new_prv->rect[1], rect, bhead->len);
+ } else {
+ new_prv->rect[1] = NULL;
+ }
+ MEM_freeN(prv);
}
}
}
@@ -251,15 +248,15 @@ void BLO_blendhandle_close(BlendHandle *bh) {
/**********/
-BlendFileData *BLO_read_from_file(const char *file, ReportList *reports)
+BlendFileData *BLO_read_from_file(const char *filepath, ReportList *reports)
{
BlendFileData *bfd = NULL;
FileData *fd;
- fd = blo_openblenderfile(file, reports);
+ fd = blo_openblenderfile(filepath, reports);
if (fd) {
fd->reports= reports;
- bfd= blo_read_file_internal(fd, file);
+ bfd= blo_read_file_internal(fd, filepath);
blo_freefiledata(fd);
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index a99430cfcf0..752c0fc6883 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -489,13 +489,13 @@ static void read_file_version(FileData *fd, Main *main)
}
-static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *name, const char *relabase)
+static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *filepath, const char *relabase)
{
Main *m;
Library *lib;
char name1[FILE_MAXDIR+FILE_MAXFILE];
- strncpy(name1, name, sizeof(name1)-1);
+ BLI_strncpy(name1, filepath, sizeof(name1));
cleanup_path(relabase, name1);
// printf("blo_find_main: original in %s\n", name);
// printf("blo_find_main: converted to %s\n", name1);
@@ -513,14 +513,14 @@ static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *name, c
BLI_addtail(mainlist, m);
lib= alloc_libblock(&m->library, ID_LI, "lib");
- strncpy(lib->name, name, sizeof(lib->name)-1);
+ strncpy(lib->name, filepath, sizeof(lib->name)-1);
BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath));
m->curlib= lib;
read_file_version(fd, m);
- if(G.f & G_DEBUG) printf("blo_find_main: added new lib %s\n", name);
+ if(G.f & G_DEBUG) printf("blo_find_main: added new lib %s\n", filepath);
return m;
}
@@ -946,14 +946,14 @@ static FileData *blo_decode_and_check(FileData *fd, ReportList *reports)
/* cannot be called with relative paths anymore! */
/* on each new library added, it now checks for the current FileData and expands relativeness */
-FileData *blo_openblenderfile(const char *name, ReportList *reports)
+FileData *blo_openblenderfile(const char *filepath, ReportList *reports)
{
gzFile gzfile;
errno= 0;
- gzfile= gzopen(name, "rb");
+ gzfile= gzopen(filepath, "rb");
if (gzfile == (gzFile)Z_NULL) {
- BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", name, errno ? strerror(errno) : "Unknown error reading file");
+ BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", filepath, errno ? strerror(errno) : "Unknown error reading file");
return NULL;
} else {
FileData *fd = filedata_new();
@@ -961,7 +961,7 @@ FileData *blo_openblenderfile(const char *name, ReportList *reports)
fd->read = fd_read_gzip_from_file;
/* needed for library_append and read_libraries */
- BLI_strncpy(fd->relabase, name, sizeof(fd->relabase));
+ BLI_strncpy(fd->relabase, filepath, sizeof(fd->relabase));
return blo_decode_and_check(fd, reports);
}
@@ -4206,7 +4206,7 @@ static void direct_link_object(FileData *fd, Object *ob)
bActuator *act;
int a;
- /* weak weak... this was only meant as draw flag, now is used in give_base too */
+ /* weak weak... this was only meant as draw flag, now is used in give_base_to_objects too */
ob->flag &= ~OB_FROMGROUP;
/* loading saved files with editmode enabled works, but for undo we like
@@ -5577,20 +5577,31 @@ static void lib_link_library(FileData *UNUSED(fd), Main *main)
}
}
-/* Always call this once you havbe loaded new library data to set the relative paths correctly in relation to the blend file */
+/* Always call this once you have loaded new library data to set the relative paths correctly in relation to the blend file */
static void fix_relpaths_library(const char *basepath, Main *main)
{
Library *lib;
/* BLO_read_from_memory uses a blank filename */
- if (basepath==NULL || basepath[0] == '\0')
- return;
-
- for(lib= main->library.first; lib; lib= lib->id.next) {
- /* Libraries store both relative and abs paths, recreate relative paths,
- * relative to the blend file since indirectly linked libs will be relative to their direct linked library */
- if (strncmp(lib->name, "//", 2)==0) { /* if this is relative to begin with? */
- strncpy(lib->name, lib->filepath, sizeof(lib->name));
- BLI_path_rel(lib->name, basepath);
+ if (basepath==NULL || basepath[0] == '\0') {
+ for(lib= main->library.first; lib; lib= lib->id.next) {
+ /* when loading a linked lib into a file which has not been saved,
+ * there is nothing we can be relative to, so instead we need to make
+ * it absolute. This can happen when appending an object with a relative
+ * link into an unsaved blend file. See [#27405].
+ * The remap relative option will make it relative again on save - campbell */
+ if (strncmp(lib->name, "//", 2)==0) {
+ strncpy(lib->name, lib->filepath, sizeof(lib->name));
+ }
+ }
+ }
+ else {
+ for(lib= main->library.first; lib; lib= lib->id.next) {
+ /* Libraries store both relative and abs paths, recreate relative paths,
+ * relative to the blend file since indirectly linked libs will be relative to their direct linked library */
+ if (strncmp(lib->name, "//", 2)==0) { /* if this is relative to begin with? */
+ strncpy(lib->name, lib->filepath, sizeof(lib->name));
+ BLI_path_rel(lib->name, basepath);
+ }
}
}
}
@@ -11805,7 +11816,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
return bhead;
}
-BlendFileData *blo_read_file_internal(FileData *fd, const char *filename)
+BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
{
BHead *bhead= blo_firstbhead(fd);
BlendFileData *bfd;
@@ -11817,7 +11828,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filename)
bfd->main->versionfile= fd->fileversion;
bfd->type= BLENFILETYPE_BLEND;
- strncpy(bfd->main->name, filename, sizeof(bfd->main->name)-1);
+ strncpy(bfd->main->name, filepath, sizeof(bfd->main->name)-1);
while(bhead) {
switch(bhead->code) {
@@ -12790,12 +12801,22 @@ static void give_base_to_objects(Main *mainvar, Scene *sce, Library *lib, int is
int do_it= 0;
- if(ob->id.us==0)
+ if(ob->id.us==0) {
do_it= 1;
- else if(ob->id.us==1 && lib)
- if(ob->id.lib==lib && (ob->flag & OB_FROMGROUP) && object_in_any_scene(mainvar, ob)==0)
+ }
+ else if (lib==NULL) { /* appending */
+ if(object_in_any_scene(mainvar, ob)==0) {
+ /* when appending, make sure any indirectly loaded objects
+ * get a base else they cant be accessed at all [#27437] */
do_it= 1;
-
+ }
+ }
+ else if(ob->id.us==1 && lib) {
+ if(ob->id.lib==lib && (ob->flag & OB_FROMGROUP) && object_in_any_scene(mainvar, ob)==0) {
+ do_it= 1;
+ }
+ }
+
if(do_it) {
base= MEM_callocN( sizeof(Base), "add_ext_base");
BLI_addtail(&(sce->base), base);
@@ -12845,7 +12866,7 @@ static void give_base_to_groups(Main *mainvar, Scene *scene)
/* returns true if the item was found
* but it may already have already been appended/linked */
-static int append_named_part(const bContext *C, Main *mainl, FileData *fd, const char *name, int idcode, short flag)
+static int append_named_part(const bContext *C, Main *mainl, FileData *fd, const char *idname, int idcode, short flag)
{
Scene *scene= CTX_data_scene(C);
Object *ob;
@@ -12860,9 +12881,9 @@ static int append_named_part(const bContext *C, Main *mainl, FileData *fd, const
if(bhead->code==ENDB) endloop= 1;
else if(bhead->code==idcode) {
- char *idname= bhead_id_name(fd, bhead);
+ const char *idname_test= bhead_id_name(fd, bhead);
- if(strcmp(idname+2, name)==0) {
+ if(strcmp(idname_test + 2, idname)==0) {
found= 1;
id= is_yet_read(fd, mainl, bhead);
if(id==NULL) {
@@ -12914,10 +12935,10 @@ static int append_named_part(const bContext *C, Main *mainl, FileData *fd, const
return found;
}
-int BLO_library_append_named_part(const bContext *C, Main *mainl, BlendHandle** bh, const char *name, int idcode, short flag)
+int BLO_library_append_named_part(const bContext *C, Main *mainl, BlendHandle** bh, const char *idname, int idcode, short flag)
{
FileData *fd= (FileData*)(*bh);
- return append_named_part(C, mainl, fd, name, idcode, flag);
+ return append_named_part(C, mainl, fd, idname, idcode, flag);
}
static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r)
@@ -12942,7 +12963,7 @@ static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r)
/* common routine to append/link something from a library */
-static Main* library_append_begin(const bContext *C, FileData **fd, char *dir)
+static Main* library_append_begin(const bContext *C, FileData **fd, const char *filepath)
{
Main *mainvar= CTX_data_main(C);
Main *mainl;
@@ -12951,7 +12972,7 @@ static Main* library_append_begin(const bContext *C, FileData **fd, char *dir)
blo_split_main(&(*fd)->mainlist, mainvar);
/* which one do we need? */
- mainl = blo_find_main(*fd, &(*fd)->mainlist, dir, G.main->name);
+ mainl = blo_find_main(*fd, &(*fd)->mainlist, filepath, G.main->name);
/* needed for do_version */
mainl->versionfile= (*fd)->fileversion;
@@ -12960,10 +12981,10 @@ static Main* library_append_begin(const bContext *C, FileData **fd, char *dir)
return mainl;
}
-Main* BLO_library_append_begin(const bContext *C, BlendHandle** bh, char *dir)
+Main* BLO_library_append_begin(const bContext *C, BlendHandle** bh, const char *filepath)
{
FileData *fd= (FileData*)(*bh);
- return library_append_begin(C, &fd, dir);
+ return library_append_begin(C, &fd, filepath);
}
static void append_do_cursor(Scene *scene, Library *curlib, short flag)
@@ -13065,6 +13086,9 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in
give_base_to_objects(mainvar, scene, NULL, 0);
}
}
+ else {
+ printf("library_append_end, scene is NULL (objects wont get bases)\n");
+ }
/* has been removed... erm, why? s..ton) */
/* 20040907: looks like they are give base already in append_named_part(); -Nathan L */
/* 20041208: put back. It only linked direct, not indirect objects (ton) */
@@ -13085,30 +13109,10 @@ void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle**
*bh= (BlendHandle*)fd;
}
-/* this is a version of BLO_library_append needed by the BPython API, so
- * scripts can load data from .blend files -- see Blender.Library module.*/
-/* append to scene */
-/* this should probably be moved into the Python code anyway */
-/* tentatively removed, Python should be able to use the split functions too: */
-/* BLO_library_append_begin, BLO_library_append_end, BLO_library_append_named_part */
-#if 0
-void BLO_script_library_append(BlendHandle **bh, char *dir, const char *name,
- int idcode, short flag, Main *mainvar, Scene *scene, ReportList *reports)
+void *BLO_library_read_struct(FileData *fd, BHead *bh, const char *blockname)
{
- FileData *fd= (FileData*)(*bh);
-
- /* try to append the requested object */
- fd->reports= reports;
- library_append(mainvar, scene, name, dir, idcode, 0, &fd, NULL, 0, flag );
- if(fd) fd->reports= NULL;
-
- /* do we need to do this? */
- if(scene)
- DAG_scene_sort(bmain, scene);
-
- *bh= (BlendHandle*)fd;
+ return read_struct(fd, bh, blockname);
}
-#endif
/* ************* READ LIBRARY ************** */
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index b409e456fe6..d4e42ccde16 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -113,9 +113,9 @@ struct Main;
void blo_join_main(ListBase *mainlist);
void blo_split_main(ListBase *mainlist, struct Main *main);
-BlendFileData *blo_read_file_internal(FileData *fd, const char *filename);
+BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath);
-FileData *blo_openblenderfile(const char *name, struct ReportList *reports);
+FileData *blo_openblenderfile(const char *filepath, struct ReportList *reports);
FileData *blo_openblendermemory(void *buffer, int buffersize, struct ReportList *reports);
FileData *blo_openblendermemfile(struct MemFile *memfile, struct ReportList *reports);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 7c1a20b13d1..348405697e3 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2523,14 +2523,14 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil
}
/* return: success (1) */
-int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *reports, int *thumb)
+int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportList *reports, int *thumb)
{
char userfilename[FILE_MAXDIR+FILE_MAXFILE];
char tempname[FILE_MAXDIR+FILE_MAXFILE+1];
int file, err, write_user_block;
/* open temporary file, so we preserve the original in case we crash */
- BLI_snprintf(tempname, sizeof(tempname), "%s@", dir);
+ BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath);
file = open(tempname,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
if(file == -1) {
@@ -2542,24 +2542,32 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report
if(write_flags & G_FILE_RELATIVE_REMAP) {
char dir1[FILE_MAXDIR+FILE_MAXFILE];
char dir2[FILE_MAXDIR+FILE_MAXFILE];
- BLI_split_dirfile(dir, dir1, NULL);
+ BLI_split_dirfile(filepath, dir1, NULL);
BLI_split_dirfile(mainvar->name, dir2, NULL);
/* just incase there is some subtle difference */
BLI_cleanup_dir(mainvar->name, dir1);
BLI_cleanup_dir(mainvar->name, dir2);
- if(strcmp(dir1, dir2)==0)
+ if(BLI_path_cmp(dir1, dir2)==0) {
write_flags &= ~G_FILE_RELATIVE_REMAP;
- else
- makeFilesAbsolute(mainvar, G.main->name, NULL);
+ }
+ else {
+ if(G.relbase_valid) {
+ /* blend may not have been saved before. Tn this case
+ * we should not have any relative paths, but if there
+ * is somehow, an invalid or empty G.main->name it will
+ * print an error, dont try make the absolute in this case. */
+ makeFilesAbsolute(mainvar, G.main->name, NULL);
+ }
+ }
}
BLI_make_file_string(G.main->name, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
- write_user_block= (BLI_path_cmp(dir, userfilename) == 0);
+ write_user_block= (BLI_path_cmp(filepath, userfilename) == 0);
if(write_flags & G_FILE_RELATIVE_REMAP)
- makeFilesRelative(mainvar, dir, NULL); /* note, making relative to something OTHER then G.main->name */
+ makeFilesRelative(mainvar, filepath, NULL); /* note, making relative to something OTHER then G.main->name */
/* actual file writing */
err= write_file_handle(mainvar, file, NULL,NULL, write_user_block, write_flags, thumb);
@@ -2573,12 +2581,12 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report
int ret;
/* first write compressed to separate @.gz */
- BLI_snprintf(gzname, sizeof(gzname), "%s@.gz", dir);
+ BLI_snprintf(gzname, sizeof(gzname), "%s@.gz", filepath);
ret = BLI_gzip(tempname, gzname);
if(0==ret) {
/* now rename to real file name, and delete temp @ file too */
- if(BLI_rename(gzname, dir) != 0) {
+ if(BLI_rename(gzname, filepath) != 0) {
BKE_report(reports, RPT_ERROR, "Can't change old file. File saved with @.");
return 0;
}
@@ -2594,7 +2602,7 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report
return 0;
}
}
- else if(BLI_rename(tempname, dir) != 0) {
+ else if(BLI_rename(tempname, filepath) != 0) {
BKE_report(reports, RPT_ERROR, "Can't change old file. File saved with @");
return 0;
}
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 4edcca46935..f755df79986 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2148,7 +2148,7 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *
bAnimContext ac;
ARegion *ar;
View2D *v2d;
- int mval[2], channel_index;
+ int channel_index;
int notifierFlags = 0;
short selectmode;
float x, y;
@@ -2162,10 +2162,6 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *
ar= ac.ar;
v2d= &ar->v2d;
- /* get mouse coordinates (in region coordinates) */
- mval[0]= (event->x - ar->winrct.xmin);
- mval[1]= (event->y - ar->winrct.ymin);
-
/* select mode is either replace (deselect all, then add) or add/extend */
if (RNA_boolean_get(op->ptr, "extend"))
selectmode= SELECT_INVERT;
@@ -2179,7 +2175,7 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *
* so that the tops of channels get caught ok. Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use
* ACHANNEL_HEIGHT_HALF.
*/
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
+ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y);
UI_view2d_listview_view_to_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP, 0, (float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index);
/* handle mouse-click in the relevant channel then */
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index ff9521f1ebd..93d99c59a0e 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -107,14 +107,9 @@ static int frame_from_event(bContext *C, wmEvent *event)
{
ARegion *region= CTX_wm_region(C);
float viewx;
- int x, y;
-
- /* convert screen coordinates to region coordinates */
- x= event->x - region->winrct.xmin;
- y= event->y - region->winrct.ymin;
-
+
/* convert from region coordinates to View2D 'tot' space */
- UI_view2d_region_to_view(&region->v2d, x, y, &viewx, NULL);
+ UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &viewx, NULL);
/* round result to nearest int (frames are ints!) */
return (int)floor(viewx+0.5f);
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 04565b4c236..10886615976 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -578,9 +578,8 @@ void ANIM_keyingset_info_register (KeyingSetInfo *ksi)
}
/* Remove the given KeyingSetInfo from the list of type infos, and also remove the builtin set if appropriate */
-void ANIM_keyingset_info_unregister (const bContext *C, KeyingSetInfo *ksi)
+void ANIM_keyingset_info_unregister (Main *bmain, KeyingSetInfo *ksi)
{
- Main *bmain= CTX_data_main(C);
KeyingSet *ks, *ksn;
/* find relevant builtin KeyingSets which use this, and remove them */
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 3430b4a77f0..fbb7915ebea 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -1522,22 +1522,17 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend
/* within active object context */
/* previously known as "selectconnected_posearmature" */
static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
- ARegion *ar= CTX_wm_region(C);
+{
Object *ob= CTX_data_edit_object(C);
Bone *bone, *curBone, *next= NULL;
int extend= RNA_boolean_get(op->ptr, "extend");
- int x, y;
-
- x= event->x - ar->winrct.xmin;
- y= event->y - ar->winrct.ymin;
view3d_operator_needs_opengl(C);
if (extend)
- bone= get_nearest_bone(C, 0, x, y);
+ bone= get_nearest_bone(C, 0, event->mval[0], event->mval[1]);
else
- bone= get_nearest_bone(C, 1, x, y);
+ bone= get_nearest_bone(C, 1, event->mval[0], event->mval[1]);
if (!bone)
return OPERATOR_CANCELLED;
@@ -1606,21 +1601,17 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, wmEvent *e
bArmature *arm;
EditBone *bone, *curBone, *next;
int extend= RNA_boolean_get(op->ptr, "extend");
- int x, y;
ARegion *ar;
Object *obedit= CTX_data_edit_object(C);
arm= obedit->data;
ar= CTX_wm_region(C);
- x= event->x - ar->winrct.xmin;
- y= event->y - ar->winrct.ymin;
-
view3d_operator_needs_opengl(C);
if (extend)
- bone= get_nearest_bone(C, 0, x, y);
+ bone= get_nearest_bone(C, 0, event->mval[0], event->mval[1]);
else
- bone= get_nearest_bone(C, 1, x, y);
+ bone= get_nearest_bone(C, 1, event->mval[0], event->mval[1]);
if (!bone)
return OPERATOR_CANCELLED;
@@ -2498,8 +2489,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e
ARegion *ar;
View3D *v3d;
RegionView3D *rv3d;
- float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3];
- int mx, my, mval[2];
+ float *fp = NULL, tvec[3], oldcurs[3], mval_f[2];
int retv;
scene= CTX_data_scene(C);
@@ -2510,30 +2500,10 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e
fp= give_cursor(scene, v3d);
copy_v3_v3(oldcurs, fp);
-
- mx= event->x - ar->winrct.xmin;
- my= event->y - ar->winrct.ymin;
- project_int_noclip(ar, fp, mval);
-
- initgrabz(rv3d, fp[0], fp[1], fp[2]);
-
- if(mval[0]!=IS_CLIPPED) {
-
- window_to_3d_delta(ar, dvec, mval[0]-mx, mval[1]-my);
- sub_v3_v3v3(fp, fp, dvec);
- }
- else {
-
- dx= ((float)(mx-(ar->winx/2)))*rv3d->zfac/(ar->winx/2);
- dy= ((float)(my-(ar->winy/2)))*rv3d->zfac/(ar->winy/2);
-
- fz= rv3d->persmat[0][3]*fp[0]+ rv3d->persmat[1][3]*fp[1]+ rv3d->persmat[2][3]*fp[2]+ rv3d->persmat[3][3];
- fz= fz/rv3d->zfac;
-
- fp[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy+ rv3d->persinv[2][0]*fz)-rv3d->ofs[0];
- fp[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy+ rv3d->persinv[2][1]*fz)-rv3d->ofs[1];
- fp[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy+ rv3d->persinv[2][2]*fz)-rv3d->ofs[2];
- }
+
+ VECCOPY2D(mval_f, event->mval);
+ ED_view3d_win_to_3d(ar, fp, mval_f, tvec);
+ copy_v3_v3(fp, tvec);
/* extrude to the where new cursor is and store the operation result */
retv= armature_click_extrude_exec(C, op);
@@ -5549,6 +5519,26 @@ void ED_armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep)
BKE_animdata_fix_paths_rename(&ob->id, ob->adt, "pose.bones", oldname, newname, 0, 0, 1);
}
}
+
+ {
+ /* correct view locking */
+ bScreen *screen;
+ for(screen= G.main->screen.first; screen; screen= screen->id.next) {
+ ScrArea *sa;
+ /* add regions */
+ for(sa= screen->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl= sa->spacedata.first;
+ if(sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d= (View3D *)sl;
+ if(v3d->ob_centre && v3d->ob_centre->data == arm) {
+ if (!strcmp(v3d->ob_centre_bone, oldname)) {
+ BLI_strncpy(v3d->ob_centre_bone, newname, MAXBONENAME);
+ }
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 1fa6a88c9f3..ccb9a45af37 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -1005,7 +1005,7 @@ static void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end,
float pval[2];
project_float(ar, stk->points[i].p, pval);
- viewray(ar, v3d, pval, ray_start, ray_normal);
+ ED_view3d_win_to_ray(ar, v3d, pval, ray_start, ray_normal);
mul_v3_fl(ray_normal, distance * progress / length);
add_v3_v3(stk->points[i].p, ray_normal);
@@ -1022,6 +1022,7 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr
short cval[2];
float fp[3] = {0, 0, 0};
float dvec[3];
+ float mval_f[2];
if (last != NULL)
{
@@ -1032,7 +1033,8 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr
/* method taken from editview.c - mouse_cursor() */
project_short_noclip(ar, fp, cval);
- window_to_3d_delta(ar, dvec, cval[0] - dd->mval[0], cval[1] - dd->mval[1]);
+ VECSUB2D(mval_f, cval, dd->mval);
+ ED_view3d_win_to_delta(ar, mval_f, dvec);
sub_v3_v3v3(vec, fp, dvec);
}
@@ -1721,7 +1723,7 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S
mval[0] = vi[0];
mval[1] = vi[1];
- viewline(ar, v3d, mval, ray_start, ray_end);
+ ED_view3d_win_to_segment_clip(ar, v3d, mval, ray_start, ray_end);
isect_line_line_v3( stk->points[s_i].p,
stk->points[s_i + 1].p,
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index 5897da97f85..9e0e9374d5d 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -527,7 +527,7 @@ static int poselib_remove_exec (bContext *C, wmOperator *op)
}
/* get index (and pointer) of pose to remove */
- marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose"));
+ marker= BLI_findlink(&act->markers, RNA_enum_get(op->ptr, "pose"));
if (marker == NULL) {
BKE_reportf(op->reports, RPT_ERROR, "Invalid Pose specified %d", RNA_int_get(op->ptr, "pose"));
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index ffcbad8229c..0b582acf589 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -3309,7 +3309,7 @@ static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp,
}
}
-static short findnearestNurbvert(ViewContext *vc, short sel, int mval[2], Nurb **nurb, BezTriple **bezt, BPoint **bp)
+static short findnearestNurbvert(ViewContext *vc, short sel, const int mval[2], Nurb **nurb, BezTriple **bezt, BPoint **bp)
{
/* sel==1: selected gets a disadvantage */
/* in nurb and bezt or bp the nearest is written */
@@ -4666,7 +4666,6 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
Curve *cu;
ViewContext vc;
float location[3];
- int mval[2];
Nurb *nu;
BezTriple *bezt;
@@ -4688,10 +4687,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
copy_v3_v3(location, give_cursor(vc.scene, vc.v3d));
}
- mval[0]= event->x - vc.ar->winrct.xmin;
- mval[1]= event->y - vc.ar->winrct.ymin;
-
- view3d_get_view_aligned_coordinate(&vc, location, mval, TRUE);
+ view3d_get_view_aligned_coordinate(&vc, location, event->mval, TRUE);
RNA_float_set_array(op->ptr, "location", location);
}
@@ -4987,21 +4983,18 @@ void CURVE_OT_select_linked(wmOperatorType *ot)
static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
Object *obedit= CTX_data_edit_object(C);
- ARegion *ar= CTX_wm_region(C);
ViewContext vc;
Nurb *nu;
BezTriple *bezt;
BPoint *bp;
- int a, location[2], deselect;
+ int a, deselect;
deselect= RNA_boolean_get(op->ptr, "deselect");
- location[0]= event->x - ar->winrct.xmin;
- location[1]= event->y - ar->winrct.ymin;
view3d_operator_needs_opengl(C);
view3d_set_viewcontext(C, &vc);
- findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp);
+ findnearestNurbvert(&vc, 1, event->mval, &nu, &bezt, &bp);
if(bezt) {
a= nu->pntsu;
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index c552657df96..83dec47bf8b 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -365,7 +365,7 @@ static EnumPropertyItem prop_gpencil_convertmodes[] = {
/* convert the coordinates from the given stroke point into 3d-coordinates
* - assumes that the active space is the 3D-View
*/
-static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoint *pt, float p3d[3])
+static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoint *pt, float p3d[3], rctf *subrect)
{
Scene *scene= CTX_data_scene(C);
View3D *v3d= CTX_wm_view3d(C);
@@ -377,41 +377,43 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi
}
else {
float *fp= give_cursor(scene, v3d);
- float dvec[3];
- int mval[2];
- int mx, my;
+ float mvalf[2];
/* get screen coordinate */
if (gps->flag & GP_STROKE_2DSPACE) {
+ int mvali[2];
View2D *v2d= &ar->v2d;
- UI_view2d_view_to_region(v2d, pt->x, pt->y, &mx, &my);
+ UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali+1);
+ VECCOPY2D(mvalf, mvali);
}
else {
- mx= (int)(pt->x / 100 * ar->winx);
- my= (int)(pt->y / 100 * ar->winy);
+ if(subrect) {
+ mvalf[0]= (((float)pt->x/100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin;
+ mvalf[1]= (((float)pt->y/100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin;
+ }
+ else {
+ mvalf[0]= (float)pt->x / 100.0f * ar->winx;
+ mvalf[1]= (float)pt->y / 100.0f * ar->winy;
+ }
}
- mval[0]= mx;
- mval[1]= my;
-
+
/* convert screen coordinate to 3d coordinates
* - method taken from editview.c - mouse_cursor()
*/
- project_int_noclip(ar, fp, mval);
- window_to_3d(ar, dvec, mval[0]-mx, mval[1]-my);
- sub_v3_v3v3(p3d, fp, dvec);
+ ED_view3d_win_to_3d(ar, fp, mvalf, p3d);
}
}
/* --- */
/* convert stroke to 3d path */
-static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu)
+static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect)
{
bGPDspoint *pt;
Nurb *nu;
BPoint *bp;
int i;
-
+
/* create new 'nurb' within the curve */
nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_path(nurb)");
@@ -428,7 +430,7 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur
float p3d[3];
/* get coordinates to add at */
- gp_strokepoint_convertcoords(C, gps, pt, p3d);
+ gp_strokepoint_convertcoords(C, gps, pt, p3d, subrect);
copy_v3_v3(bp->vec, p3d);
/* set settings */
@@ -440,8 +442,27 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur
BLI_addtail(&cu->nurb, nu);
}
+static int gp_camera_view_subrect(bContext *C, rctf *subrect)
+{
+ Scene *scene= CTX_data_scene(C);
+ View3D *v3d= CTX_wm_view3d(C);
+ ARegion *ar= CTX_wm_region(C);
+
+ if (v3d) {
+ RegionView3D *rv3d= ar->regiondata;
+
+ /* for camera view set the subrect */
+ if (rv3d->persp == RV3D_CAMOB) {
+ view3d_calc_camera_border(scene, ar, NULL, v3d, subrect, -1); /* negative shift */
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
/* convert stroke to 3d bezier */
-static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu)
+static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect)
{
bGPDspoint *pt;
Nurb *nu;
@@ -463,9 +484,9 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C
/* get initial coordinates */
pt=gps->points;
if (tot) {
- gp_strokepoint_convertcoords(C, gps, pt, p3d_cur);
+ gp_strokepoint_convertcoords(C, gps, pt, p3d_cur, subrect);
if (tot > 1) {
- gp_strokepoint_convertcoords(C, gps, pt+1, p3d_next);
+ gp_strokepoint_convertcoords(C, gps, pt+1, p3d_next, subrect);
}
}
@@ -493,7 +514,7 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C
copy_v3_v3(p3d_cur, p3d_next);
if (i + 1 < tot) {
- gp_strokepoint_convertcoords(C, gps, pt+1, p3d_next);
+ gp_strokepoint_convertcoords(C, gps, pt+1, p3d_next, subrect);
}
}
@@ -512,7 +533,10 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short
bGPDstroke *gps;
Object *ob;
Curve *cu;
-
+
+ /* camera framing */
+ rctf subrect, *subrect_ptr= NULL;
+
/* error checking */
if (ELEM3(NULL, gpd, gpl, gpf))
return;
@@ -521,6 +545,11 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short
if (gpf->strokes.first == NULL)
return;
+ /* initialize camera framing */
+ if(gp_camera_view_subrect(C, &subrect)) {
+ subrect_ptr= &subrect;
+ }
+
/* init the curve object (remove rotation and get curve data from it)
* - must clear transforms set on object, as those skew our results
*/
@@ -538,10 +567,10 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short
for (gps= gpf->strokes.first; gps; gps= gps->next) {
switch (mode) {
case GP_STROKECONVERT_PATH:
- gp_stroke_to_path(C, gpl, gps, cu);
+ gp_stroke_to_path(C, gpl, gps, cu, subrect_ptr);
break;
case GP_STROKECONVERT_CURVE:
- gp_stroke_to_bezier(C, gpl, gps, cu);
+ gp_stroke_to_bezier(C, gpl, gps, cu, subrect_ptr);
break;
}
}
@@ -564,8 +593,6 @@ static int gp_convert_layer_exec (bContext *C, wmOperator *op)
bGPdata *gpd= gpencil_data_get_active(C);
bGPDlayer *gpl= gpencil_layer_getactive(gpd);
Scene *scene= CTX_data_scene(C);
- View3D *v3d= CTX_wm_view3d(C);
- float *fp= give_cursor(scene, v3d);
int mode= RNA_enum_get(op->ptr, "type");
/* check if there's data to work with */
@@ -574,9 +601,6 @@ static int gp_convert_layer_exec (bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* initialise 3d-cursor correction globals */
- initgrabz(CTX_wm_region_view3d(C), fp[0], fp[1], fp[2]);
-
/* handle conversion modes */
switch (mode) {
case GP_STROKECONVERT_PATH:
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index f1672dce2bd..eafdfc9881e 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -209,7 +209,7 @@ static void gp_get_3d_reference (tGPsdata *p, float *vec)
/* Stroke Editing ---------------------------- */
/* check if the current mouse position is suitable for adding a new point */
-static short gp_stroke_filtermval (tGPsdata *p, int mval[2], int pmval[2])
+static short gp_stroke_filtermval (tGPsdata *p, const int mval[2], int pmval[2])
{
int dx= abs(mval[0] - pmval[0]);
int dy= abs(mval[1] - pmval[1]);
@@ -238,21 +238,22 @@ static short gp_stroke_filtermval (tGPsdata *p, int mval[2], int pmval[2])
/* convert screen-coordinates to buffer-coordinates */
// XXX this method needs a total overhaul!
-static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], float *depth)
+static void gp_stroke_convertcoords (tGPsdata *p, const int mval[2], float out[3], float *depth)
{
bGPdata *gpd= p->gpd;
/* in 3d-space - pt->x/y/z are 3 side-by-side floats */
if (gpd->sbuffer_sflag & GP_STROKE_3DSPACE) {
- if (gpencil_project_check(p) && (view_autodist_simple(p->ar, mval, out, 0, depth))) {
+ if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval, out, 0, depth))) {
/* projecting onto 3D-Geometry
* - nothing more needs to be done here, since view_autodist_simple() has already done it
*/
}
else {
- const int mx=mval[0], my=mval[1];
+ int mval_prj[2];
float rvec[3], dvec[3];
-
+ float mval_f[2];
+
/* Current method just converts each point in screen-coordinates to
* 3D-coordinates using the 3D-cursor as reference. In general, this
* works OK, but it could of course be improved.
@@ -265,20 +266,17 @@ static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], flo
gp_get_3d_reference(p, rvec);
/* method taken from editview.c - mouse_cursor() */
- project_int_noclip(p->ar, rvec, mval);
- window_to_3d_delta(p->ar, dvec, mval[0]-mx, mval[1]-my);
+ project_int_noclip(p->ar, rvec, mval_prj);
+
+ VECSUB2D(mval_f, mval_prj, mval);
+ ED_view3d_win_to_delta(p->ar, mval_f, dvec);
sub_v3_v3v3(out, rvec, dvec);
}
}
/* 2d - on 'canvas' (assume that p->v2d is set) */
else if ((gpd->sbuffer_sflag & GP_STROKE_2DSPACE) && (p->v2d)) {
- float x, y;
-
- UI_view2d_region_to_view(p->v2d, mval[0], mval[1], &x, &y);
-
- out[0]= x;
- out[1]= y;
+ UI_view2d_region_to_view(p->v2d, mval[0], mval[1], &out[0], &out[1]);
}
#if 0
@@ -314,7 +312,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], flo
}
/* add current stroke-point to buffer (returns whether point was successfully added) */
-static short gp_stroke_addpoint (tGPsdata *p, int mval[2], float pressure)
+static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure)
{
bGPdata *gpd= p->gpd;
tGPspoint *pt;
@@ -582,8 +580,8 @@ static void gp_stroke_newfrombuffer (tGPsdata *p)
for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) {
mval[0]= ptc->x; mval[1]= ptc->y;
- if ((view_autodist_depth(p->ar, mval, depth_margin, depth_arr+i) == 0) &&
- (i && (view_autodist_depth_segment(p->ar, mval, mval_prev, depth_margin + 1, depth_arr+i) == 0))
+ if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr+i) == 0) &&
+ (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr+i) == 0))
) {
interp_depth= TRUE;
}
@@ -1227,7 +1225,7 @@ static void gp_paint_strokeend (tGPsdata *p)
/* need to restore the original projection settings before packing up */
view3d_region_operator_needs_opengl(p->win, p->ar);
- view_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0);
+ ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0);
}
/* check if doing eraser or not */
@@ -1415,16 +1413,15 @@ static void gpencil_draw_apply (wmOperator *op, tGPsdata *p)
static void gpencil_draw_apply_event (wmOperator *op, wmEvent *event)
{
tGPsdata *p= op->customdata;
- ARegion *ar= p->ar;
PointerRNA itemptr;
float mousef[2];
int tablet=0;
/* convert from window-space to area-space mouse coordintes */
// NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding...
- p->mval[0]= event->x - ar->winrct.xmin + 1;
- p->mval[1]= event->y - ar->winrct.ymin + 1;
-
+ p->mval[0]= event->mval[0] + 1;
+ p->mval[1]= event->mval[1] + 1;
+
/* handle pressure sensitivity (which is supplied by tablets) */
if (event->custom == EVT_DATA_TABLET) {
wmTabletData *wmtab= event->customdata;
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 7bab563641a..6523a897713 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -36,6 +36,7 @@
extern "C" {
#endif
+struct Main;
struct ListBase;
struct ID;
struct Scene;
@@ -190,7 +191,7 @@ KeyingSetInfo *ANIM_keyingset_info_find_named(const char name[]);
/* for RNA type registrations... */
void ANIM_keyingset_info_register(KeyingSetInfo *ksi);
-void ANIM_keyingset_info_unregister(const struct bContext *C, KeyingSetInfo *ksi);
+void ANIM_keyingset_info_unregister(struct Main *bmain, KeyingSetInfo *ksi);
/* cleanup on exit */
void ANIM_keyingset_infos_exit(void);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 4e693bb819c..afb70491a12 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -83,9 +83,73 @@ typedef struct ViewDepths {
float *give_cursor(struct Scene *scene, struct View3D *v3d);
int initgrabz(struct RegionView3D *rv3d, float x, float y, float z);
-void window_to_3d(struct ARegion *ar, float out[3], const int mx, const int my);
-void window_to_3d_delta(struct ARegion *ar, float out[3], const int mx, const int my);
-void window_to_3d_vector(struct ARegion *ar, float out[3], const int mx, const int my);
+
+/**
+ * Calculate a 3d location from 2d window coordinates.
+ * @param ar The region (used for the window width and height).
+ * @param depth_pt The reference location used to calculate the Z depth.
+ * @param mval The area relative location (such as event->mval converted to floats).
+ * @param out The resulting world-space location.
+ */
+void ED_view3d_win_to_3d(struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]);
+
+/**
+ * Calculate a 3d difference vector from 2d window offset.
+ * note that initgrabz() must be called first to determine
+ * the depth used to calculate the delta.
+ * @param ar The region (used for the window width and height).
+ * @param mval The area relative 2d difference (such as event->mval[0] - other_x).
+ * @param out The resulting world-space delta.
+ */
+void ED_view3d_win_to_delta(struct ARegion *ar, const float mval[2], float out[3]);
+
+/**
+ * Calculate a 3d direction vector from 2d window coordinates.
+ * This direction vector starts and the view in the direction of the 2d window coordinates.
+ * In orthographic view all window coordinates yield the same vector.
+ * @param ar The region (used for the window width and height).
+ * @param mval The area relative 2d location (such as event->mval converted to floats).
+ * @param out The resulting normalized world-space direction vector.
+ */
+void ED_view3d_win_to_vector(struct ARegion *ar, const float mval[2], float out[3]);
+
+/**
+ * Calculate a 3d segment from 2d window coordinates.
+ * This ray_start is located at the viewpoint, ray_end is a far point.
+ * ray_start and ray_end are clipped by the view near and far limits
+ * so points along this line are always in view.
+ * In orthographic view all resulting segments will be parallel.
+ * @param ar The region (used for the window width and height).
+ * @param v3d The 3d viewport (used for near and far clipping range).
+ * @param mval The area relative 2d location (such as event->mval, converted into float[2]).
+ * @param ray_start The world-space starting point of the segment.
+ * @param ray_end The world-space end point of the segment.
+ */
+void ED_view3d_win_to_segment_clip(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]);
+
+/**
+ * Calculate a 3d viewpoint and direction vector from 2d window coordinates.
+ * This ray_start is located at the viewpoint, ray_normal is the direction towards mval.
+ * ray_start is clipped by the view near limit so points in front of it are always in view.
+ * In orthographic view the resulting ray_normal will match the view vector.
+ * @param ar The region (used for the window width and height).
+ * @param v3d The 3d viewport (used for near clipping value).
+ * @param out The resulting normalized world-space direction vector.
+ * @param mval The area relative 2d location (such as event->mval, converted into float[2]).
+ * @param ray_start The world-space starting point of the segment.
+ * @param ray_normal The normalized world-space direction of towards mval.
+ */
+void ED_view3d_win_to_ray(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3]);
+
+/**
+ * Calculate a normalized 3d direction vector from the viewpoint towards a global location.
+ * In orthographic view the resulting vector will match the view vector.
+ * @param ar The region (used for the window width and height).
+ * @param coord The world-space location.
+ * @param vec The resulting normalized vector.
+ */
+void ED_view3d_global_to_vector(struct RegionView3D *rv3d, const float coord[3], float vec[3]);
+
void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z);
/* Depth buffer */
@@ -107,15 +171,9 @@ void project_int_noclip(struct ARegion *ar, const float vec[3], int adr[2]);
void project_float(struct ARegion *ar, const float vec[3], float adr[2]);
void project_float_noclip(struct ARegion *ar, const float vec[3], float adr[2]);
-void viewvector(struct RegionView3D *rv3d, float coord[3], float vec[3]);
-
-void viewline(struct ARegion *ar, struct View3D *v3d, float mval[2], float ray_start[3], float ray_end[3]);
-void viewray(struct ARegion *ar, struct View3D *v3d, float mval[2], float ray_start[3], float ray_normal[3]);
-
void get_object_clip_range(struct Object *ob, float *lens, float *clipsta, float *clipend);
int get_view3d_cliprange(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend);
int get_view3d_viewplane(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend, float *pixsize);
-int get_view3d_ortho(struct View3D *v3d, struct RegionView3D *rv3d);
void view3d_get_object_project_mat(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]);
void view3d_project_float(struct ARegion *a, const float vec[3], float adr[2], float mat[4][4]);
void view3d_project_float_v3(struct ARegion *a, float *vec, float *adr, float mat[4][4]);
@@ -143,13 +201,13 @@ unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, const int mval[2
unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y);
/* draws and does a 4x4 sample */
-int view_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, const int mval[2], float mouse_worldloc[3]);
+int ED_view3d_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, const int mval[2], float mouse_worldloc[3]);
-/* only draw so view_autodist_simple can be called many times after */
-int view_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode);
-int view_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth);
-int view_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth);
-int view_autodist_depth_segment(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth);
+/* only draw so ED_view3d_autodist_simple can be called many times after */
+int ED_view3d_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode);
+int ED_view3d_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth);
+int ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth);
+int ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth);
/* select */
#define MAXPICKBUF 10000
@@ -203,8 +261,4 @@ void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d);
/* copy the view to the camera */
void ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d);
-int view3d_is_ortho(struct View3D *v3d, struct RegionView3D *rv3d);
-
-
#endif /* ED_VIEW3D_H */
-
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index e2910d33b12..be46a7c7b85 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -298,7 +298,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
after->func_arg3= but->func_arg3;
after->funcN= but->funcN;
- after->func_argN= but->func_argN;
+ after->func_argN= MEM_dupallocN(but->func_argN);
after->rename_func= but->rename_func;
after->rename_arg1= but->rename_arg1;
@@ -402,6 +402,8 @@ static void ui_apply_but_funcs_after(bContext *C)
after.func(C, after.func_arg1, after.func_arg2);
if(after.funcN)
after.funcN(C, after.func_argN, after.func_arg2);
+ if(after.func_argN)
+ MEM_freeN(after.func_argN);
if(after.handle_func)
after.handle_func(C, after.handle_func_arg, after.retval);
@@ -4020,12 +4022,9 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut
static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
-{
- ARegion *ar= CTX_wm_region(C);
-
- but->linkto[0]= event->x-ar->winrct.xmin;
- but->linkto[1]= event->y-ar->winrct.ymin;
-
+{
+ VECCOPY2D(but->linkto, event->mval);
+
if(data->state == BUTTON_STATE_HIGHLIGHT) {
if(event->type == LEFTMOUSE && event->val==KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_WAIT_RELEASE);
@@ -5532,10 +5531,6 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men
int closer;
if(!menu->dotowards) return 0;
- if((block->direction & UI_TOP) || (block->direction & UI_DOWN)) {
- menu->dotowards= 0;
- return menu->dotowards;
- }
/* verify that we are moving towards one of the edges of the
* menu block, in other words, in the triangle formed by the
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index a33068ae3fd..a62e7b30120 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -418,6 +418,9 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
but->type= NUMSLI;
}
}
+ else if(subtype == PROP_DIRECTION) {
+ uiDefButR(block, BUT_NORMAL, 0, name, x, y, UI_UNIT_X*3, UI_UNIT_Y*3, ptr, RNA_property_identifier(prop), 0, 0, 0, -1, -1, NULL);
+ }
else {
if(ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA) && !expand)
uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, 0, 0, w, UI_UNIT_Y);
@@ -533,9 +536,6 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
/* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */
but= uiDefIconButO(block, BUT, "BUTTONS_OT_file_browse", WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL);
}
- else if(subtype == PROP_DIRECTION) {
- uiDefButR(block, BUT_NORMAL, 0, name, x, y, 100, 100, ptr, RNA_property_identifier(prop), index, 0, 0, -1, -1, NULL);
- }
else if(flag & UI_ITEM_R_EVENT) {
uiDefButR(block, KEYEVT, 0, name, x, y, w, h, ptr, RNA_property_identifier(prop), index, 0, 0, -1, -1, NULL);
}
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 84cf5af5414..eb522a1d2b8 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -44,6 +44,7 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
+#include "BKE_screen.h"
#include "BKE_global.h"
@@ -1959,17 +1960,14 @@ View2D *UI_view2d_fromcontext(const bContext *C)
/* same as above, but it returns regionwindow. Utility for pulldowns or buttons */
View2D *UI_view2d_fromcontext_rwin(const bContext *C)
{
- ScrArea *area= CTX_wm_area(C);
+ ScrArea *sa= CTX_wm_area(C);
ARegion *region= CTX_wm_region(C);
- if (area == NULL) return NULL;
+ if (sa == NULL) return NULL;
if (region == NULL) return NULL;
if (region->regiontype!=RGN_TYPE_WINDOW) {
- ARegion *ar= area->regionbase.first;
- for(; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_WINDOW)
- return &(ar->v2d);
- return NULL;
+ ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ return ar ? &(ar->v2d) : NULL;
}
return &(region->v2d);
}
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 4cb67994704..f7bff168a33 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -702,7 +702,7 @@ static int view_zoomin_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* store initial mouse position (in view space) */
UI_view2d_region_to_view(&ar->v2d,
- event->x - ar->winrct.xmin, event->y - ar->winrct.ymin,
+ event->mval[0], event->mval[1],
&vzd->mx_2d, &vzd->my_2d);
}
@@ -759,7 +759,7 @@ static int view_zoomout_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* store initial mouse position (in view space) */
UI_view2d_region_to_view(&ar->v2d,
- event->x - ar->winrct.xmin, event->y - ar->winrct.ymin,
+ event->mval[0], event->mval[1],
&vzd->mx_2d, &vzd->my_2d);
}
@@ -936,7 +936,7 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* store initial mouse position (in view space) */
UI_view2d_region_to_view(&ar->v2d,
- event->x - ar->winrct.xmin, event->y - ar->winrct.ymin,
+ event->mval[0], event->mval[1],
&vzd->mx_2d, &vzd->my_2d);
}
@@ -1286,7 +1286,6 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
ARegion *ar= CTX_wm_region(C);
View2D *v2d= &ar->v2d;
float mask_size;
- int x, y;
/* set custom-data for operator */
vsm= MEM_callocN(sizeof(v2dScrollerMove), "v2dScrollerMove");
@@ -1300,8 +1299,6 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
/* store mouse-coordinates, and convert mouse/screen coordinates to region coordinates */
vsm->lastx = event->x;
vsm->lasty = event->y;
- x= event->x - ar->winrct.xmin;
- y= event->y - ar->winrct.ymin;
/* 'zone' depends on where mouse is relative to bubble
* - zooming must be allowed on this axis, otherwise, default to pan
@@ -1313,7 +1310,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
vsm->fac= (v2d->tot.xmax - v2d->tot.xmin) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
- vsm->zone= mouse_in_scroller_handle(x, v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max);
+ vsm->zone= mouse_in_scroller_handle(event->mval[0], v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max);
if ((v2d->keepzoom & V2D_LOCKZOOM_X) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) {
/* default to scroll, as handles not usable */
@@ -1328,7 +1325,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
vsm->fac= (v2d->tot.ymax - v2d->tot.ymin) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
- vsm->zone= mouse_in_scroller_handle(y, v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max);
+ vsm->zone= mouse_in_scroller_handle(event->mval[1], v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max);
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) {
/* default to scroll, as handles not usable */
diff --git a/source/blender/editors/mesh/editbmesh_bvh.c b/source/blender/editors/mesh/editbmesh_bvh.c
index f238f817d9d..fcefeb6ce6b 100644
--- a/source/blender/editors/mesh/editbmesh_bvh.c
+++ b/source/blender/editors/mesh/editbmesh_bvh.c
@@ -665,16 +665,16 @@ int BMBVH_EdgeVisible(BMBVHTree *tree, BMEdge *e, ARegion *ar, View3D *v3d, Obje
float co1[3], co2[3], co3[3], dir1[4], dir2[4], dir3[4];
float origin[3], invmat[4][4];
float epsilon = 0.01f;
- float m[2], end[3];
+ float mval_f[2], end[3];
if (!ar) {
printf("error in BMBVH_EdgeVisible!\n");
return 0;
}
- m[0] = ar->winx/2.0;
- m[1] = ar->winy/2.0;
- viewline(ar, v3d, m, origin, end);
+ mval_f[0] = ar->winx/2.0;
+ mval_f[1] = ar->winy/2.0;
+ ED_view3d_win_to_segment_clip(ar, v3d, mval_f, origin, end);
invert_m4_m4(invmat, obedit->obmat);
mul_m4_v3(invmat, origin);
diff --git a/source/blender/editors/mesh/knifetool.c b/source/blender/editors/mesh/knifetool.c
index 3b8ab2f748f..7184d99ff3b 100755
--- a/source/blender/editors/mesh/knifetool.c
+++ b/source/blender/editors/mesh/knifetool.c
@@ -927,8 +927,8 @@ static void knife_find_line_hits(knifetool_opdata *kcd)
return;
/*unproject screen line*/
- viewline(kcd->ar, kcd->vc.v3d, s1, v1, v3);
- viewline(kcd->ar, kcd->vc.v3d, s2, v2, v4);
+ ED_view3d_win_to_segment_clip(kcd->ar, kcd->vc.v3d, s1, v1, v3);
+ ED_view3d_win_to_segment_clip(kcd->ar, kcd->vc.v3d, s2, v2, v4);
/*view3d_unproject(&mats, v1, s1[0], s1[1], 0.0f);
view3d_unproject(&mats, v2, s2[0], s2[1], 0.0f);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 15986fad3d8..1ce702b0a69 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -1505,13 +1505,7 @@ static int select_linked_exec(bContext *C, wmOperator *op)
static int select_linked_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- ARegion *ar= CTX_wm_region(C);
- int location[2];
-
- location[0]= event->x - ar->winrct.xmin;
- location[1]= event->y - ar->winrct.ymin;
- RNA_int_set_array(op->ptr, "location", location);
-
+ RNA_int_set_array(op->ptr, "location", event->mval);
return select_linked_exec(C, op);
}
@@ -3251,7 +3245,7 @@ static int brush_add(PEData *data, short number)
mco[0]= data->mval[0] + dmx;
mco[1]= data->mval[1] + dmy;
- viewline(data->vc.ar, data->vc.v3d, mco, co1, co2);
+ ED_view3d_win_to_segment_clip(data->vc.ar, data->vc.v3d, mco, co1, co2);
mul_m4_v3(imat,co1);
mul_m4_v3(imat,co2);
@@ -3508,6 +3502,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
switch(pset->brushtype) {
case PE_BRUSH_COMB:
{
+ float mval_f[2];
data.mval= mval;
data.rad= (float)brush->size;
@@ -3519,7 +3514,9 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
invert_m4_m4(ob->imat, ob->obmat);
- window_to_3d_delta(ar, vec, dx, dy);
+ mval_f[0]= dx;
+ mval_f[1]= dy;
+ ED_view3d_win_to_delta(ar, mval_f, vec);
data.dvec= vec;
foreach_mouse_hit_key(&data, brush_comb, selected);
@@ -3683,12 +3680,10 @@ static int brush_edit_exec(bContext *C, wmOperator *op)
static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event)
{
- ARegion *ar= CTX_wm_region(C);
PointerRNA itemptr;
float mouse[2];
- mouse[0]= event->x - ar->winrct.xmin;
- mouse[1]= event->y - ar->winrct.ymin;
+ VECCOPY2D(mouse, event->mval);
/* fill in stroke */
RNA_collection_add(op->ptr, "stroke", &itemptr);
diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt
index e8c23954f65..61c26df5ac8 100644
--- a/source/blender/editors/render/CMakeLists.txt
+++ b/source/blender/editors/render/CMakeLists.txt
@@ -42,6 +42,8 @@ set(SRC
render_ops.c
render_preview.c
render_shading.c
+ render_update.c
+ render_view.c
render_intern.h
)
diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h
index e6d8c98d068..ab09acd67f4 100644
--- a/source/blender/editors/render/render_intern.h
+++ b/source/blender/editors/render/render_intern.h
@@ -65,13 +65,16 @@ void TEXTURE_OT_envmap_clear(struct wmOperatorType *ot);
void TEXTURE_OT_envmap_clear_all(struct wmOperatorType *ot);
/* render_internal.c */
-void RENDER_OT_view_show(struct wmOperatorType *ot);
void RENDER_OT_render(struct wmOperatorType *ot);
-void RENDER_OT_view_cancel(struct wmOperatorType *ot);
-/*render_opengl.c uses these */
+/* render_opengl.c uses this */
void image_buffer_rect_update(struct Scene *scene, struct RenderResult *rr, struct ImBuf *ibuf, volatile struct rcti *renrect);
-void screen_set_image_output(struct bContext *C, int mx, int my);
+
+/* render_view.c */
+void render_view_open(struct bContext *C, int mx, int my);
+
+void RENDER_OT_view_show(struct wmOperatorType *ot);
+void RENDER_OT_view_cancel(struct wmOperatorType *ot);
/* render_opengl.c */
void RENDER_OT_opengl(struct wmOperatorType *ot);
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 7f90e298504..6191ec9c035 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -73,17 +73,14 @@
#include "render_intern.h"
-static ScrArea *biggest_area(bContext *C);
-static ScrArea *biggest_non_image_area(bContext *C);
-static ScrArea *find_area_showing_r_result(bContext *C, wmWindow **win);
-static ScrArea *find_area_image_empty(bContext *C);
+/* Render Callbacks */
/* called inside thread! */
void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volatile rcti *renrect)
{
float x1, y1, *rectf= NULL;
int ymin, ymax, xmin, xmax;
- int rymin, rxmin;
+ int rymin, rxmin, do_color_management;
char *rectc;
/* if renrect argument, we only refresh scanlines */
@@ -95,7 +92,8 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
/* xmin here is first subrect x coord, xmax defines subrect width */
xmin = renrect->xmin + rr->crop;
xmax = renrect->xmax - xmin + rr->crop;
- if (xmax<2) return;
+ if(xmax<2)
+ return;
ymin= renrect->ymin + rr->crop;
ymax= renrect->ymax - ymin + rr->crop;
@@ -141,270 +139,56 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
rectf+= 4*(rr->rectx*ymin + xmin);
rectc= (char *)(ibuf->rect + ibuf->x*rymin + rxmin);
+
+ do_color_management = (scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT));
/* XXX make nice consistent functions for this */
- if (scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
- for(y1= 0; y1<ymax; y1++) {
- float *rf= rectf;
- float srgb[3];
- char *rc= rectc;
- const float dither = ibuf->dither / 255.0f;
-
- /* XXX temp. because crop offset */
- if( rectc >= (char *)(ibuf->rect)) {
- for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
- const float d = (BLI_frand()-0.5f)*dither;
- srgb[0]= d + linearrgb_to_srgb(rf[0]);
- srgb[1]= d + linearrgb_to_srgb(rf[1]);
- srgb[2]= d + linearrgb_to_srgb(rf[2]);
-
- rc[0]= FTOCHAR(srgb[0]);
- rc[1]= FTOCHAR(srgb[1]);
- rc[2]= FTOCHAR(srgb[2]);
- rc[3]= FTOCHAR(rf[3]);
+ for(y1= 0; y1<ymax; y1++) {
+ float *rf= rectf;
+ float srgb[3];
+ char *rc= rectc;
+ const float dither = ibuf->dither / 255.0f;
+
+ /* XXX temp. because crop offset */
+ if(rectc >= (char *)(ibuf->rect)) {
+ for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
+ /* color management */
+ if(do_color_management) {
+ srgb[0]= linearrgb_to_srgb(rf[0]);
+ srgb[1]= linearrgb_to_srgb(rf[1]);
+ srgb[2]= linearrgb_to_srgb(rf[2]);
}
- }
- rectf += 4*rr->rectx;
- rectc += 4*ibuf->x;
- }
- } else {
- for(y1= 0; y1<ymax; y1++) {
- float *rf= rectf;
- char *rc= rectc;
- float rgb[3];
- const float dither = ibuf->dither / 255.0f;
-
- /* XXX temp. because crop offset */
- if( rectc >= (char *)(ibuf->rect)) {
- for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
- const float d = (BLI_frand()-0.5f)*dither;
-
- rgb[0] = d + rf[0];
- rgb[1] = d + rf[1];
- rgb[2] = d + rf[2];
-
- rc[0]= FTOCHAR(rgb[0]);
- rc[1]= FTOCHAR(rgb[1]);
- rc[2]= FTOCHAR(rgb[2]);
- rc[3]= FTOCHAR(rf[3]);
+ else {
+ copy_v3_v3(srgb, rf);
}
- }
- rectf += 4*rr->rectx;
- rectc += 4*ibuf->x;
- }
- }
-}
-/* new window uses x,y to set position */
-void screen_set_image_output(bContext *C, int mx, int my)
-{
- wmWindow *win= CTX_wm_window(C);
- Scene *scene= CTX_data_scene(C);
- ScrArea *sa= NULL;
- SpaceImage *sima;
- int area_was_image=0;
-
- if(scene->r.displaymode==R_OUTPUT_NONE)
- return;
-
- if(scene->r.displaymode==R_OUTPUT_WINDOW) {
- rcti rect;
- int sizex, sizey;
-
- sizex= 10 + (scene->r.xsch*scene->r.size)/100;
- sizey= 40 + (scene->r.ysch*scene->r.size)/100;
-
- /* arbitrary... miniature image window views don't make much sense */
- if(sizex < 320) sizex= 320;
- if(sizey < 256) sizey= 256;
-
- /* XXX some magic to calculate postition */
- rect.xmin= mx + win->posx - sizex/2;
- rect.ymin= my + win->posy - sizey/2;
- rect.xmax= rect.xmin + sizex;
- rect.ymax= rect.ymin + sizey;
-
- /* changes context! */
- WM_window_open_temp(C, &rect, WM_WINDOW_RENDER);
-
- sa= CTX_wm_area(C);
- }
- else if(scene->r.displaymode==R_OUTPUT_SCREEN) {
- if (CTX_wm_area(C) && CTX_wm_area(C)->spacetype == SPACE_IMAGE)
- area_was_image = 1;
-
- /* this function returns with changed context */
- ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE);
- sa= CTX_wm_area(C);
- }
+ /* dither */
+ if(dither != 0.0f) {
+ const float d = (BLI_frand()-0.5f)*dither;
- if(!sa) {
- sa= find_area_showing_r_result(C, &win);
- if(sa==NULL)
- sa= find_area_image_empty(C);
-
- /* if area found in other window, we make that one show in front */
- if(win && win!=CTX_wm_window(C))
- wm_window_raise(win);
-
- if(sa==NULL) {
- /* find largest open non-image area */
- sa= biggest_non_image_area(C);
- if(sa) {
- ED_area_newspace(C, sa, SPACE_IMAGE);
- sima= sa->spacedata.first;
-
- /* makes ESC go back to prev space */
- sima->flag |= SI_PREVSPACE;
- }
- else {
- /* use any area of decent size */
- sa= biggest_area(C);
- if(sa->spacetype!=SPACE_IMAGE) {
- // XXX newspace(sa, SPACE_IMAGE);
- sima= sa->spacedata.first;
-
- /* makes ESC go back to prev space */
- sima->flag |= SI_PREVSPACE;
+ srgb[0] += d;
+ srgb[1] += d;
+ srgb[2] += d;
}
- }
- }
- }
- sima= sa->spacedata.first;
- /* get the correct image, and scale it */
- sima->image= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
-
-
- /* if we're rendering to full screen, set appropriate hints on image editor
- * so it can restore properly on pressing esc */
- if(sa->full) {
- sima->flag |= SI_FULLWINDOW;
-
- /* Tell the image editor to revert to previous space in space list on close
- * _only_ if it wasn't already an image editor when the render was invoked */
- if (area_was_image == 0)
- sima->flag |= SI_PREVSPACE;
- else {
- /* Leave it alone so the image editor will just go back from
- * full screen to the original tiled setup */
- ;
+ /* write */
+ rc[0]= FTOCHAR(srgb[0]);
+ rc[1]= FTOCHAR(srgb[1]);
+ rc[2]= FTOCHAR(srgb[2]);
+ rc[3]= FTOCHAR(rf[3]);
+ }
}
+ rectf += 4*rr->rectx;
+ rectc += 4*ibuf->x;
}
-
}
-
/* ****************************** render invoking ***************** */
/* set callbacks, exported to sequence render too.
Only call in foreground (UI) renders. */
-/* returns biggest area that is not uv/image editor. Note that it uses buttons */
-/* window as the last possible alternative. */
-static ScrArea *biggest_non_image_area(bContext *C)
-{
- bScreen *sc= CTX_wm_screen(C);
- ScrArea *sa, *big= NULL;
- int size, maxsize= 0, bwmaxsize= 0;
- short foundwin= 0;
-
- for(sa= sc->areabase.first; sa; sa= sa->next) {
- if(sa->winx > 30 && sa->winy > 30) {
- size= sa->winx*sa->winy;
- if(sa->spacetype == SPACE_BUTS) {
- if(foundwin == 0 && size > bwmaxsize) {
- bwmaxsize= size;
- big= sa;
- }
- }
- else if(sa->spacetype != SPACE_IMAGE && size > maxsize) {
- maxsize= size;
- big= sa;
- foundwin= 1;
- }
- }
- }
-
- return big;
-}
-
-static ScrArea *biggest_area(bContext *C)
-{
- bScreen *sc= CTX_wm_screen(C);
- ScrArea *sa, *big= NULL;
- int size, maxsize= 0;
-
- for(sa= sc->areabase.first; sa; sa= sa->next) {
- size= sa->winx*sa->winy;
- if(size > maxsize) {
- maxsize= size;
- big= sa;
- }
- }
- return big;
-}
-
-
-static ScrArea *find_area_showing_r_result(bContext *C, wmWindow **win)
-{
- wmWindowManager *wm= CTX_wm_manager(C);
- ScrArea *sa = NULL;
- SpaceImage *sima;
-
- /* find an imagewindow showing render result */
- for(*win=wm->windows.first; *win; *win= (*win)->next) {
- for(sa= (*win)->screen->areabase.first; sa; sa= sa->next) {
- if(sa->spacetype==SPACE_IMAGE) {
- sima= sa->spacedata.first;
- if(sima->image && sima->image->type==IMA_TYPE_R_RESULT)
- break;
- }
- }
- if(sa)
- break;
- }
-
- return sa;
-}
-
-static ScrArea *find_area_image_empty(bContext *C)
-{
- bScreen *sc= CTX_wm_screen(C);
- ScrArea *sa;
- SpaceImage *sima;
-
- /* find an imagewindow showing render result */
- for(sa=sc->areabase.first; sa; sa= sa->next) {
- if(sa->spacetype==SPACE_IMAGE) {
- sima= sa->spacedata.first;
- if(!sima->image)
- break;
- }
- }
- return sa;
-}
-
-#if 0 // XXX not used
-static ScrArea *find_empty_image_area(bContext *C)
-{
- bScreen *sc= CTX_wm_screen(C);
- ScrArea *sa;
- SpaceImage *sima;
-
- /* find an imagewindow showing render result */
- for(sa=sc->areabase.first; sa; sa= sa->next) {
- if(sa->spacetype==SPACE_IMAGE) {
- sima= sa->spacedata.first;
- if(!sima->image)
- break;
- }
- }
- return sa;
-}
-#endif // XXX not used
-
static void render_error_reports(void *reports, const char *str)
{
BKE_report(reports, RPT_ERROR, str);
@@ -428,10 +212,6 @@ static int screen_render_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if(re==NULL) {
- re= RE_NewRender(scene->id.name);
- }
-
G.afbreek= 0;
RE_test_break_cb(re, NULL, (int (*)(void *)) blender_test_break);
RE_error_cb(re, op->reports, render_error_reports);
@@ -558,7 +338,7 @@ static void render_progress_update(void *rjv, float progress)
{
RenderJob *rj= rjv;
- if (rj->progress)
+ if(rj->progress)
*rj->progress = progress;
}
@@ -731,7 +511,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
// store spare
/* ensure at least 1 area shows result */
- screen_set_image_output(C, event->x, event->y);
+ render_view_open(C, event->x, event->y);
jobflag= WM_JOB_EXCL_RENDER|WM_JOB_PRIORITY|WM_JOB_PROGRESS;
@@ -835,119 +615,3 @@ void RENDER_OT_render(wmOperatorType *ot)
RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME-2, "Scene", "Re-render single layer in this scene");
}
-/* ****************************** opengl render *************************** */
-
-
-/* *********************** cancel render viewer *************** */
-
-static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op))
-{
- wmWindow *win= CTX_wm_window(C);
- ScrArea *sa= CTX_wm_area(C);
- SpaceImage *sima= sa->spacedata.first;
-
- /* test if we have a temp screen in front */
- if(CTX_wm_window(C)->screen->temp) {
- wm_window_lower(CTX_wm_window(C));
- return OPERATOR_FINISHED;
- }
- /* determine if render already shows */
- else if(sima->flag & SI_PREVSPACE) {
- sima->flag &= ~SI_PREVSPACE;
-
- if(sima->flag & SI_FULLWINDOW) {
- sima->flag &= ~SI_FULLWINDOW;
- ED_screen_full_prevspace(C, sa);
- }
- else
- ED_area_prevspace(C, sa);
-
- return OPERATOR_FINISHED;
- }
- else if(sima->flag & SI_FULLWINDOW) {
- sima->flag &= ~SI_FULLWINDOW;
- ED_screen_full_toggle(C, win, sa);
- return OPERATOR_FINISHED;
- }
-
- return OPERATOR_PASS_THROUGH;
-}
-
-void RENDER_OT_view_cancel(struct wmOperatorType *ot)
-{
- /* identifiers */
- ot->name= "Cancel Render View";
- ot->description= "Cancel show render view";
- ot->idname= "RENDER_OT_view_cancel";
-
- /* api callbacks */
- ot->exec= render_view_cancel_exec;
- ot->poll= ED_operator_image_active;
-}
-
-/* *********************** show render viewer *************** */
-
-static int render_view_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
-{
- wmWindow *wincur = CTX_wm_window(C);
-
- /* test if we have currently a temp screen active */
- if(wincur->screen->temp) {
- wm_window_lower(wincur);
- }
- else {
- wmWindow *win, *winshow;
- ScrArea *sa= find_area_showing_r_result(C, &winshow);
-
- /* is there another window showing result? */
- for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
- if(win->screen->temp || (win==winshow && winshow!=wincur)) {
- wm_window_raise(win);
- return OPERATOR_FINISHED;
- }
- }
-
- /* determine if render already shows */
- if(sa) {
- /* but don't close it when rendering */
- if(!G.rendering) {
- SpaceImage *sima= sa->spacedata.first;
-
- if(sima->flag & SI_PREVSPACE) {
- sima->flag &= ~SI_PREVSPACE;
-
- if(sima->flag & SI_FULLWINDOW) {
- sima->flag &= ~SI_FULLWINDOW;
- ED_screen_full_prevspace(C, sa);
- }
- else if(sima->next) {
- /* workaround for case of double prevspace, render window
- with a file browser on top of it (same as in ED_area_prevspace) */
- if(sima->next->spacetype == SPACE_FILE && sima->next->next)
- ED_area_newspace(C, sa, sima->next->next->spacetype);
- else
- ED_area_newspace(C, sa, sima->next->spacetype);
- ED_area_tag_redraw(sa);
- }
- }
- }
- }
- else {
- screen_set_image_output(C, event->x, event->y);
- }
- }
-
- return OPERATOR_FINISHED;
-}
-
-void RENDER_OT_view_show(struct wmOperatorType *ot)
-{
- /* identifiers */
- ot->name= "Show/Hide Render View";
- ot->description= "Toggle show render view";
- ot->idname= "RENDER_OT_view_show";
-
- /* api callbacks */
- ot->invoke= render_view_show_invoke;
- ot->poll= ED_operator_screenactive;
-}
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 626fbce1b2e..0a279e412f6 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -527,7 +527,7 @@ static int screen_opengl_render_invoke(bContext *C, wmOperator *op, wmEvent *eve
}
oglrender= op->customdata;
- screen_set_image_output(C, event->x, event->y);
+ render_view_open(C, event->x, event->y);
WM_event_add_modal_handler(C, op);
oglrender->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 1abf5df223c..2404805c17b 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -74,7 +74,9 @@
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_node.h"
+#include "BKE_object.h"
#include "BKE_texture.h"
+#include "BKE_world.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -97,15 +99,6 @@
#include "render_intern.h"
-#define PR_XMIN 10
-#define PR_YMIN 5
-#define PR_XMAX 200
-#define PR_YMAX 195
-
-/* XXX */
-static int qtest(void) {return 0;}
-/* XXX */
-
ImBuf* get_brush_icon(Brush *brush)
{
static const int flags = IB_rect|IB_multilayer|IB_metadata;
@@ -158,9 +151,11 @@ typedef struct ShaderPreview {
ID *parent;
MTex *slot;
- /* node materials/texture need full copy during preview render, glsl uses it too */
+ /* datablocks with nodes need full copy during preview render, glsl uses it too */
Material *matcopy;
Tex *texcopy;
+ Lamp *lampcopy;
+ World *worldcopy;
float col[4]; /* active object color */
@@ -170,123 +165,6 @@ typedef struct ShaderPreview {
} ShaderPreview;
-
-
-/* unused now */
-void draw_tex_crop(Tex *tex)
-{
- rcti rct;
- int ret= 0;
-
- if(tex==NULL) return;
-
- if(tex->type==TEX_IMAGE) {
- if(tex->cropxmin==0.0f) ret++;
- if(tex->cropymin==0.0f) ret++;
- if(tex->cropxmax==1.0f) ret++;
- if(tex->cropymax==1.0f) ret++;
- if(ret==4) return;
-
- rct.xmin= PR_XMIN+2+tex->cropxmin*(PR_XMAX-PR_XMIN-4);
- rct.xmax= PR_XMIN+2+tex->cropxmax*(PR_XMAX-PR_XMIN-4);
- rct.ymin= PR_YMIN+2+tex->cropymin*(PR_YMAX-PR_YMIN-4);
- rct.ymax= PR_YMIN+2+tex->cropymax*(PR_YMAX-PR_YMIN-4);
-
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-
- glColor3ub(0, 0, 0);
- glRecti(rct.xmin+1, rct.ymin-1, rct.xmax+1, rct.ymax-1);
-
- glColor3ub(255, 255, 255);
- glRecti(rct.xmin, rct.ymin, rct.xmax, rct.ymax);
-
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- }
-
-}
-
-/* temporal abuse; if id_code is -1 it only does texture.... solve! */
-void BIF_preview_changed(short UNUSED(id_code))
-{
-#if 0
- ScrArea *sa;
-
- for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
- if(sa->spacetype==SPACE_BUTS) {
- SpaceButs *sbuts= sa->spacedata.first;
- if(sbuts->mainb==CONTEXT_SHADING) {
- int tab= sbuts->tab[CONTEXT_SHADING];
- if(tab==TAB_SHADING_MAT && (id_code==ID_MA || id_code==ID_TE)) {
- if (sbuts->ri) sbuts->ri->curtile= 0;
- addafterqueue(sa->win, RENDERPREVIEW, 1);
- }
- else if(tab==TAB_SHADING_TEX && (id_code==ID_TE || id_code==-1)) {
- if (sbuts->ri) sbuts->ri->curtile= 0;
- addafterqueue(sa->win, RENDERPREVIEW, 1);
- }
- else if(tab==TAB_SHADING_LAMP && (id_code==ID_LA || id_code==ID_TE)) {
- if (sbuts->ri) sbuts->ri->curtile= 0;
- addafterqueue(sa->win, RENDERPREVIEW, 1);
- }
- else if(tab==TAB_SHADING_WORLD && (id_code==ID_WO || id_code==ID_TE)) {
- if (sbuts->ri) sbuts->ri->curtile= 0;
- addafterqueue(sa->win, RENDERPREVIEW, 1);
- }
- }
- else if (sbuts->ri)
- sbuts->ri->curtile= 0; /* ensure changes always result in re-render when context is restored */
- }
- else if(sa->spacetype==SPACE_NODE) {
- SpaceNode *snode= sa->spacedata.first;
- if(snode->treetype==NTREE_SHADER && (id_code==ID_MA || id_code==ID_TE)) {
- snode_tag_dirty(snode);
- }
- }
- else if(sa->spacetype==SPACE_VIEW3D) {
- View3D *vd= sa->spacedata.first;
- /* if is has a renderinfo, we consider that reason for signalling */
- if (vd->ri) {
- vd->ri->curtile= 0;
- addafterqueue(sa->win, RENDERPREVIEW, 1);
- }
- }
- }
-
- if(ELEM4(id_code, ID_MA, ID_TE, ID_LA, ID_WO)) {
- Object *ob;
- Material *ma;
-
- if(id_code == ID_WO) {
- for(ma=G.main->mat.first; ma; ma=ma->id.next) {
- if(ma->gpumaterial.first) {
- GPU_material_free(ma);
- }
- }
- }
- else if(id_code == ID_LA) {
- for(ob=G.main->object.first; ob; ob=ob->id.next) {
- if(ob->gpulamp.first) {
- GPU_lamp_free(ob);
- }
- }
-
- for(ma=G.main->mat.first; ma; ma=ma->id.next) {
- if(ma->gpumaterial.first) {
- GPU_material_free(ma);
- }
- }
- } else if(OBACT) {
- Object *ob = OBACT;
-
- ma= give_current_material(ob, ob->actcol);
- if(ma && ma->gpumaterial.first) {
- GPU_material_free(ma);
- }
- }
- }
-#endif
-}
-
/* *************************** Preview for buttons *********************** */
static Main *pr_main= NULL;
@@ -385,7 +263,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
if(id_type==ID_MA) {
Material *mat= NULL, *origmat= (Material *)id;
- if(id) {
+ if(origmat) {
/* work on a copy */
mat= localize_material(origmat);
sp->matcopy= mat;
@@ -515,7 +393,14 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
}
}
else if(id_type==ID_LA) {
- Lamp *la= (Lamp *)id;
+ Lamp *la= NULL, *origla= (Lamp *)id;
+
+ /* work on a copy */
+ if(origla) {
+ la= localize_lamp(origla);
+ sp->lampcopy= la;
+ BLI_addtail(&pr_main->lamp, la);
+ }
if(la && la->type==LA_SUN && (la->sun_effect_type & LA_SUN_EFFECT_SKY)) {
sce->lay= 1<<MA_ATMOS;
@@ -537,8 +422,16 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
}
}
else if(id_type==ID_WO) {
+ World *wrld= NULL, *origwrld= (World *)id;
+
+ if(origwrld) {
+ wrld= localize_world(origwrld);
+ sp->worldcopy= wrld;
+ BLI_addtail(&pr_main->world, wrld);
+ }
+
sce->lay= 1<<MA_SKY;
- sce->world= (World *)id;
+ sce->world= wrld;
}
return sce;
@@ -636,321 +529,6 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
}
}
-/* ******************************** Icon Preview **************************** */
-
-void ED_preview_icon_draw(const bContext *UNUSED(C), void *UNUSED(idp), void *UNUSED(arg1), void *UNUSED(arg2), rcti *UNUSED(rect))
-{
-}
-
-/* *************************** Preview for 3d window *********************** */
-
-void view3d_previewrender_progress(RenderResult *rr, volatile rcti *renrect)
-{
-// ScrArea *sa= NULL; // XXX
-// View3D *v3d= NULL; // XXX
- RenderLayer *rl;
- int ofsx=0, ofsy=0;
-
- if(renrect) return;
-
- rl= rr->layers.first;
-
- /* this case is when we render envmaps... */
-// if(rr->rectx > v3d->ri->pr_rectx || rr->recty > v3d->ri->pr_recty)
-// return;
-
-// ofsx= v3d->ri->disprect.xmin + rr->tilerect.xmin;
-// ofsy= v3d->ri->disprect.ymin + rr->tilerect.ymin;
-
- glDrawBuffer(GL_FRONT);
-// glaDefine2DArea(&sa->winrct);
- glaDrawPixelsSafe_to32(ofsx, ofsy, rr->rectx, rr->recty, rr->rectx, rl->rectf, 0);
- bglFlush();
- glDrawBuffer(GL_BACK);
-
-}
-
-void BIF_view3d_previewrender_signal(ScrArea *UNUSED(sa), short UNUSED(signal))
-{
-#if 0
- View3D *v3d= sa->spacedata.first;
-
- /* this can be called from other window... solve! */
- if(sa->spacetype!=SPACE_VIEW3D)
- return; // XXX
-
- if(v3d && v3d->ri) {
- RenderInfo *ri= v3d->ri;
- ri->status &= ~signal;
- ri->curtile= 0;
- //printf("preview signal %d\n", signal);
- if(ri->re && (signal & PR_DBASE))
- RE_Database_Free(ri->re);
-
-// addafterqueue(sa->win, RENDERPREVIEW, 1);
- }
-#endif
-}
-
-void BIF_view3d_previewrender_free(View3D *UNUSED(v3d))
-{
-#if 0
- if(v3d->ri) {
- RenderInfo *ri= v3d->ri;
- if(ri->re) {
-// printf("free render\n");
- RE_Database_Free(ri->re);
- RE_FreeRender(ri->re);
- ri->re= NULL;
- }
- if (v3d->ri->rect) MEM_freeN(v3d->ri->rect);
- MEM_freeN(v3d->ri);
- v3d->ri= NULL;
- }
-#endif
-}
-
-/* returns 1 if OK, do not call while in panel space! */
-static int view3d_previewrender_get_rects(ScrArea *sa, rctf *viewplane, RenderInfo *ri, float *clipsta, float *clipend, int *ortho, float *pixsize)
-{
- View3D *v3d= NULL; // XXX
- RegionView3D *rv3d= NULL; // XXX
- int rectx, recty;
-// uiBlock *block;
-
-// block= uiFindOpenPanelBlockName(&sa->uiblocks, "Preview");
-// if(block==NULL) return 0;
-
- /* calculate preview rect size */
-// BLI_init_rctf(viewplane, 15.0f, (block->maxx - block->minx)-15.0f, 15.0f, (block->maxy - block->miny)-15.0f);
-// uiPanelPush(block);
-// ui_graphics_to_window_rct(sa->win, viewplane, &ri->disprect);
-// uiPanelPop(block);
-
- /* correction for gla draw */
-// BLI_translate_rcti(&ri->disprect, -sa->winrct.xmin, -sa->winrct.ymin);
-
- *ortho= get_view3d_viewplane(v3d, rv3d, sa->winx, sa->winy, viewplane, clipsta, clipend, pixsize);
-
- rectx= ri->disprect.xmax - ri->disprect.xmin;
- recty= ri->disprect.ymax - ri->disprect.ymin;
-
- if(rectx<4 || recty<4) return 0;
-
- if(ri->rect && (rectx!=ri->pr_rectx || recty!=ri->pr_recty)) {
- MEM_freeN(ri->rect);
- ri->rect= NULL;
- ri->curtile= 0;
- printf("changed size\n");
- }
- ri->pr_rectx= rectx;
- ri->pr_recty= recty;
-
- return 1;
-}
-
-/* called before a panel gets moved/scaled, makes sure we can see through */
-void BIF_view3d_previewrender_clear(ScrArea *UNUSED(sa))
-{
-#if 0
- View3D *v3d= sa->spacedata.first;
-
- if(v3d->ri) {
- RenderInfo *ri= v3d->ri;
- ri->curtile= 0;
- if(ri->rect)
- MEM_freeN(ri->rect);
- ri->rect= NULL;
- }
-#endif
-}
-
-/* afterqueue call */
-void BIF_view3d_previewrender(Main *bmain, Scene *scene, ScrArea *sa)
-{
- View3D *v3d= sa->spacedata.first;
- RegionView3D *rv3d= NULL; // XXX
- Render *re;
- RenderInfo *ri=NULL; /* preview struct! */
- RenderStats *rstats;
- RenderData rdata;
- rctf viewplane;
- float clipsta, clipend, pixsize;
- int orth;
-
- /* first get the render info right */
-// if (!v3d->ri) {
-// ri= v3d->ri= MEM_callocN(sizeof(RenderInfo), "butsrenderinfo");
-// ri->tottile= 10000;
-// }
-// ri= v3d->ri;
-
- if(0==view3d_previewrender_get_rects(sa, &viewplane, ri, &clipsta, &clipend, &orth, &pixsize))
- return;
-
- /* render is finished, so return */
- if(ri->tottile && ri->curtile>=ri->tottile) return;
-
- /* or return with a new event */
- if(qtest()) {
-// addafterqueue(sa->win, RENDERPREVIEW, 1);
- return;
- }
- //printf("Enter previewrender\n");
- /* ok, are we rendering all over? */
- if(ri->re==NULL) {
- char name[32];
-
- ri->status= 0;
-
- sprintf(name, "View3dPreview %p", (void *)sa);
- re= ri->re= RE_NewRender(name);
- //RE_display_draw_cb(re, view3d_previewrender_progress);
- //RE_stats_draw_cb(re, view3d_previewrender_stats);
- //RE_test_break_cb(re, qtest);
-
- /* no osa, blur, seq, layers, etc for preview render */
- rdata= scene->r;
- rdata.mode &= ~(R_OSA|R_MBLUR);
- rdata.scemode &= ~(R_DOSEQ|R_DOCOMP|R_FREE_IMAGE);
- rdata.layers.first= rdata.layers.last= NULL;
- rdata.renderer= R_INTERN;
-
- RE_InitState(re, NULL, &rdata, NULL, sa->winx, sa->winy, &ri->disprect);
-
- if(orth)
- RE_SetOrtho(re, &viewplane, clipsta, clipend);
- else
- RE_SetWindow(re, &viewplane, clipsta, clipend);
- RE_SetPixelSize(re, pixsize);
-
- /* until here are no escapes */
- ri->status |= PR_DISPRECT;
- ri->curtile= 0;
- //printf("new render\n");
- }
-
- re= ri->re;
-
- PIL_sleep_ms(100); /* wait 0.1 second if theres really no event... */
- if(qtest()==0) {
-
- /* check status */
- if((ri->status & PR_DISPRECT)==0) {
- RE_SetDispRect(ri->re, &ri->disprect);
- if(orth)
- RE_SetOrtho(ri->re, &viewplane, clipsta, clipend);
- else
- RE_SetWindow(ri->re, &viewplane, clipsta, clipend);
- RE_SetPixelSize(re, pixsize);
- ri->status |= PR_DISPRECT;
- ri->curtile= 0;
- //printf("disprect update\n");
- }
- if((ri->status & PR_DBASE)==0) {
- unsigned int lay= scene->lay;
-
- RE_SetView(re, rv3d->viewmat);
-
- /* allow localview render for objects with lights in normal layers */
- if(v3d->lay & 0xFF000000)
- lay |= v3d->lay;
- else lay= v3d->lay;
-
- RE_Database_FromScene(re, bmain, scene, lay, 0); // 0= dont use camera view
-
- rstats= RE_GetStats(re);
- if(rstats->convertdone)
- ri->status |= PR_DBASE|PR_PROJECTED|PR_ROTATED;
- ri->curtile= 0;
-
- /* database can have created render-resol data... */
- if(rstats->convertdone)
- DAG_scene_flush_update(bmain, scene, scene->lay, 0);
-
- //printf("dbase update\n");
- }
- if((ri->status & PR_PROJECTED)==0) {
- if(ri->status & PR_DBASE) {
- if(orth)
- RE_SetOrtho(ri->re, &viewplane, clipsta, clipend);
- else
- RE_SetWindow(ri->re, &viewplane, clipsta, clipend);
- RE_DataBase_ApplyWindow(re);
- ri->status |= PR_PROJECTED;
- }
- ri->curtile= 0;
- //printf("project update\n");
- }
-
- /* OK, can we enter render code? */
- if(ri->status==(PR_DISPRECT|PR_DBASE|PR_PROJECTED|PR_ROTATED)) {
- //printf("curtile %d tottile %d\n", ri->curtile, ri->tottile);
- RE_TileProcessor(ri->re); //, ri->curtile, 0);
-
- if(ri->rect==NULL)
- ri->rect= MEM_mallocN(sizeof(int)*ri->pr_rectx*ri->pr_recty, "preview view3d rect");
-
- RE_ResultGet32(ri->re, ri->rect);
- }
-
- rstats= RE_GetStats(ri->re);
-// if(rstats->totpart==rstats->partsdone && rstats->partsdone)
-// addqueue(sa->win, REDRAW, 1);
-// else
-// addafterqueue(sa->win, RENDERPREVIEW, 1);
-
- ri->curtile= rstats->partsdone;
- ri->tottile= rstats->totpart;
- }
- else {
-// addafterqueue(sa->win, RENDERPREVIEW, 1);
- }
-
- //printf("\n");
-}
-
-/* in panel space! */
-static void view3d_previewdraw_rect(ScrArea *UNUSED(sa), uiBlock *UNUSED(block), RenderInfo *ri)
-{
-// rctf dispf;
-
- if(ri->rect==NULL)
- return;
-
-// BLI_init_rctf(&dispf, 15.0f, (block->maxx - block->minx)-15.0f, 15.0f, (block->maxy - block->miny)-15.0f);
-// ui_graphics_to_window_rct(sa->win, &dispf, &ri->disprect);
-
- /* correction for gla draw */
-// BLI_translate_rcti(&ri->disprect, -sa->winrct.xmin, -sa->winrct.ymin);
-
- /* when panel scale changed, free rect */
- if(ri->disprect.xmax-ri->disprect.xmin != ri->pr_rectx ||
- ri->disprect.ymax-ri->disprect.ymin != ri->pr_recty) {
- MEM_freeN(ri->rect);
- ri->rect= NULL;
- }
- else {
-// glaDefine2DArea(&sa->winrct);
- glaDrawPixelsSafe(ri->disprect.xmin, ri->disprect.ymin, ri->pr_rectx, ri->pr_recty, ri->pr_rectx, GL_RGBA, GL_UNSIGNED_BYTE, ri->rect);
- }
-}
-
-/* is panel callback, supposed to be called with correct panel offset matrix */
-void BIF_view3d_previewdraw(struct ScrArea *sa, struct uiBlock *block)
-{
- RegionView3D *rv3d= NULL;
-
-// if (v3d->ri==NULL || v3d->ri->rect==NULL)
-// addafterqueue(sa->win, RENDERPREVIEW, 1);
-// else {
- view3d_previewdraw_rect(sa, block, rv3d->ri);
-// if(v3d->ri->curtile==0)
-// addafterqueue(sa->win, RENDERPREVIEW, 1);
-// }
-}
-
-
/* **************************** new shader preview system ****************** */
/* inside thread, called by renderer, sets job update value */
@@ -1148,6 +726,38 @@ static void shader_preview_free(void *customdata)
}
MEM_freeN(sp->texcopy);
}
+ if(sp->worldcopy) {
+ struct IDProperty *properties;
+ /* node previews */
+ shader_preview_updatejob(sp);
+
+ /* get rid of copied world */
+ BLI_remlink(&pr_main->world, sp->worldcopy);
+ free_world(sp->worldcopy);
+
+ properties= IDP_GetProperties((ID *)sp->worldcopy, FALSE);
+ if (properties) {
+ IDP_FreeProperty(properties);
+ MEM_freeN(properties);
+ }
+ MEM_freeN(sp->worldcopy);
+ }
+ if(sp->lampcopy) {
+ struct IDProperty *properties;
+ /* node previews */
+ shader_preview_updatejob(sp);
+
+ /* get rid of copied lamp */
+ BLI_remlink(&pr_main->lamp, sp->lampcopy);
+ free_lamp(sp->lampcopy);
+
+ properties= IDP_GetProperties((ID *)sp->lampcopy, FALSE);
+ if (properties) {
+ IDP_FreeProperty(properties);
+ MEM_freeN(properties);
+ }
+ MEM_freeN(sp->lampcopy);
+ }
MEM_freeN(sp);
}
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 281afa69744..ea4a4f43ca3 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -88,180 +88,6 @@
#include "render_intern.h" // own include
-/***************************** Updates ***********************************
- * ED_render_id_flush_update gets called from DAG_id_tag_update, to do *
- * editor level updates when the ID changes. when these ID blocks are in *
- * the dependency graph, we can get rid of the manual dependency checks */
-
-static int mtex_use_tex(MTex **mtex, int tot, Tex *tex)
-{
- int a;
-
- if(!mtex)
- return 0;
-
- for(a=0; a<tot; a++)
- if(mtex[a] && mtex[a]->tex == tex)
- return 1;
-
- return 0;
-}
-
-static int nodes_use_tex(bNodeTree *ntree, Tex *tex)
-{
- bNode *node;
-
- for(node=ntree->nodes.first; node; node= node->next) {
- if(node->id) {
- if(node->id == (ID*)tex) {
- return 1;
- }
- else if(node->type==NODE_GROUP) {
- if(nodes_use_tex((bNodeTree *)node->id, tex))
- return 1;
- }
- }
- }
-
- return 0;
-}
-
-static void material_changed(Main *UNUSED(bmain), Material *ma)
-{
- /* icons */
- BKE_icon_changed(BKE_icon_getid(&ma->id));
-
- /* glsl */
- if(ma->gpumaterial.first)
- GPU_material_free(ma);
-}
-
-static void texture_changed(Main *bmain, Tex *tex)
-{
- Material *ma;
- Lamp *la;
- World *wo;
-
- /* icons */
- BKE_icon_changed(BKE_icon_getid(&tex->id));
-
- /* find materials */
- for(ma=bmain->mat.first; ma; ma=ma->id.next) {
- if(mtex_use_tex(ma->mtex, MAX_MTEX, tex));
- else if(ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex));
- else continue;
-
- BKE_icon_changed(BKE_icon_getid(&ma->id));
-
- if(ma->gpumaterial.first)
- GPU_material_free(ma);
- }
-
- /* find lamps */
- for(la=bmain->lamp.first; la; la=la->id.next) {
- if(mtex_use_tex(la->mtex, MAX_MTEX, tex));
- else continue;
-
- BKE_icon_changed(BKE_icon_getid(&la->id));
- }
-
- /* find worlds */
- for(wo=bmain->world.first; wo; wo=wo->id.next) {
- if(mtex_use_tex(wo->mtex, MAX_MTEX, tex));
- else continue;
-
- BKE_icon_changed(BKE_icon_getid(&wo->id));
- }
-}
-
-static void lamp_changed(Main *bmain, Lamp *la)
-{
- Object *ob;
- Material *ma;
-
- /* icons */
- BKE_icon_changed(BKE_icon_getid(&la->id));
-
- /* glsl */
- for(ob=bmain->object.first; ob; ob=ob->id.next)
- if(ob->data == la && ob->gpulamp.first)
- GPU_lamp_free(ob);
-
- for(ma=bmain->mat.first; ma; ma=ma->id.next)
- if(ma->gpumaterial.first)
- GPU_material_free(ma);
-}
-
-static void world_changed(Main *bmain, World *wo)
-{
- Material *ma;
-
- /* icons */
- BKE_icon_changed(BKE_icon_getid(&wo->id));
-
- /* glsl */
- for(ma=bmain->mat.first; ma; ma=ma->id.next)
- if(ma->gpumaterial.first)
- GPU_material_free(ma);
-}
-
-static void image_changed(Main *bmain, Image *ima)
-{
- Tex *tex;
-
- /* icons */
- BKE_icon_changed(BKE_icon_getid(&ima->id));
-
- /* textures */
- for(tex=bmain->tex.first; tex; tex=tex->id.next)
- if(tex->ima == ima)
- texture_changed(bmain, tex);
-}
-
-static void scene_changed(Main *bmain, Scene *UNUSED(scene))
-{
- Object *ob;
- Material *ma;
-
- /* glsl */
- for(ob=bmain->object.first; ob; ob=ob->id.next)
- if(ob->gpulamp.first)
- GPU_lamp_free(ob);
-
- for(ma=bmain->mat.first; ma; ma=ma->id.next)
- if(ma->gpumaterial.first)
- GPU_material_free(ma);
-}
-
-void ED_render_id_flush_update(Main *bmain, ID *id)
-{
- if(!id)
- return;
-
- switch(GS(id->name)) {
- case ID_MA:
- material_changed(bmain, (Material*)id);
- break;
- case ID_TE:
- texture_changed(bmain, (Tex*)id);
- break;
- case ID_WO:
- world_changed(bmain, (World*)id);
- break;
- case ID_LA:
- lamp_changed(bmain, (Lamp*)id);
- break;
- case ID_IM:
- image_changed(bmain, (Image*)id);
- break;
- case ID_SCE:
- scene_changed(bmain, (Scene*)id);
- break;
- default:
- break;
- }
-}
-
/********************** material slot operators *********************/
static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
@@ -1263,3 +1089,4 @@ void TEXTURE_OT_slot_paste(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
new file mode 100644
index 00000000000..98f42fe97c1
--- /dev/null
+++ b/source/blender/editors/render/render_update.c
@@ -0,0 +1,238 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/render/render_shading.c
+ * \ingroup edrend
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_lamp_types.h"
+#include "DNA_material_types.h"
+#include "DNA_node_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_view3d_types.h"
+#include "DNA_world_types.h"
+
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+#include "BKE_depsgraph.h"
+#include "BKE_icons.h"
+#include "BKE_image.h"
+#include "BKE_main.h"
+#include "BKE_material.h"
+#include "BKE_node.h"
+#include "BKE_scene.h"
+#include "BKE_texture.h"
+#include "BKE_world.h"
+
+#include "GPU_material.h"
+
+#include "ED_render.h"
+
+#include "render_intern.h" // own include
+
+/***************************** Updates ***********************************
+ * ED_render_id_flush_update gets called from DAG_id_tag_update, to do *
+ * editor level updates when the ID changes. when these ID blocks are in *
+ * the dependency graph, we can get rid of the manual dependency checks */
+
+static int mtex_use_tex(MTex **mtex, int tot, Tex *tex)
+{
+ int a;
+
+ if(!mtex)
+ return 0;
+
+ for(a=0; a<tot; a++)
+ if(mtex[a] && mtex[a]->tex == tex)
+ return 1;
+
+ return 0;
+}
+
+static int nodes_use_tex(bNodeTree *ntree, Tex *tex)
+{
+ bNode *node;
+
+ for(node=ntree->nodes.first; node; node= node->next) {
+ if(node->id) {
+ if(node->id == (ID*)tex) {
+ return 1;
+ }
+ else if(node->type==NODE_GROUP) {
+ if(nodes_use_tex((bNodeTree *)node->id, tex))
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static void material_changed(Main *UNUSED(bmain), Material *ma)
+{
+ /* icons */
+ BKE_icon_changed(BKE_icon_getid(&ma->id));
+
+ /* glsl */
+ if(ma->gpumaterial.first)
+ GPU_material_free(ma);
+}
+
+static void texture_changed(Main *bmain, Tex *tex)
+{
+ Material *ma;
+ Lamp *la;
+ World *wo;
+
+ /* icons */
+ BKE_icon_changed(BKE_icon_getid(&tex->id));
+
+ /* find materials */
+ for(ma=bmain->mat.first; ma; ma=ma->id.next) {
+ if(mtex_use_tex(ma->mtex, MAX_MTEX, tex));
+ else if(ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex));
+ else continue;
+
+ BKE_icon_changed(BKE_icon_getid(&ma->id));
+
+ if(ma->gpumaterial.first)
+ GPU_material_free(ma);
+ }
+
+ /* find lamps */
+ for(la=bmain->lamp.first; la; la=la->id.next) {
+ if(mtex_use_tex(la->mtex, MAX_MTEX, tex));
+ else continue;
+
+ BKE_icon_changed(BKE_icon_getid(&la->id));
+ }
+
+ /* find worlds */
+ for(wo=bmain->world.first; wo; wo=wo->id.next) {
+ if(mtex_use_tex(wo->mtex, MAX_MTEX, tex));
+ else continue;
+
+ BKE_icon_changed(BKE_icon_getid(&wo->id));
+ }
+}
+
+static void lamp_changed(Main *bmain, Lamp *la)
+{
+ Object *ob;
+ Material *ma;
+
+ /* icons */
+ BKE_icon_changed(BKE_icon_getid(&la->id));
+
+ /* glsl */
+ for(ob=bmain->object.first; ob; ob=ob->id.next)
+ if(ob->data == la && ob->gpulamp.first)
+ GPU_lamp_free(ob);
+
+ for(ma=bmain->mat.first; ma; ma=ma->id.next)
+ if(ma->gpumaterial.first)
+ GPU_material_free(ma);
+}
+
+static void world_changed(Main *bmain, World *wo)
+{
+ Material *ma;
+
+ /* icons */
+ BKE_icon_changed(BKE_icon_getid(&wo->id));
+
+ /* glsl */
+ for(ma=bmain->mat.first; ma; ma=ma->id.next)
+ if(ma->gpumaterial.first)
+ GPU_material_free(ma);
+}
+
+static void image_changed(Main *bmain, Image *ima)
+{
+ Tex *tex;
+
+ /* icons */
+ BKE_icon_changed(BKE_icon_getid(&ima->id));
+
+ /* textures */
+ for(tex=bmain->tex.first; tex; tex=tex->id.next)
+ if(tex->ima == ima)
+ texture_changed(bmain, tex);
+}
+
+static void scene_changed(Main *bmain, Scene *UNUSED(scene))
+{
+ Object *ob;
+ Material *ma;
+
+ /* glsl */
+ for(ob=bmain->object.first; ob; ob=ob->id.next)
+ if(ob->gpulamp.first)
+ GPU_lamp_free(ob);
+
+ for(ma=bmain->mat.first; ma; ma=ma->id.next)
+ if(ma->gpumaterial.first)
+ GPU_material_free(ma);
+}
+
+void ED_render_id_flush_update(Main *bmain, ID *id)
+{
+ if(!id)
+ return;
+
+ switch(GS(id->name)) {
+ case ID_MA:
+ material_changed(bmain, (Material*)id);
+ break;
+ case ID_TE:
+ texture_changed(bmain, (Tex*)id);
+ break;
+ case ID_WO:
+ world_changed(bmain, (World*)id);
+ break;
+ case ID_LA:
+ lamp_changed(bmain, (Lamp*)id);
+ break;
+ case ID_IM:
+ image_changed(bmain, (Image*)id);
+ break;
+ case ID_SCE:
+ scene_changed(bmain, (Scene*)id);
+ break;
+ default:
+ break;
+ }
+}
+
diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c
new file mode 100644
index 00000000000..64a4d47cddc
--- /dev/null
+++ b/source/blender/editors/render/render_view.c
@@ -0,0 +1,359 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/render/render_view.c
+ * \ingroup edrend
+ */
+
+#include <string.h>
+#include <stddef.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+
+#include "DNA_scene_types.h"
+
+#include "BKE_blender.h"
+#include "BKE_context.h"
+#include "BKE_image.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BKE_node.h"
+#include "BKE_report.h"
+#include "BKE_screen.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_screen.h"
+
+#include "wm_window.h"
+
+#include "render_intern.h"
+
+/*********************** utilities for finding areas *************************/
+
+/* returns biggest area that is not uv/image editor. Note that it uses buttons */
+/* window as the last possible alternative. */
+static ScrArea *biggest_non_image_area(bContext *C)
+{
+ bScreen *sc= CTX_wm_screen(C);
+ ScrArea *sa, *big= NULL;
+ int size, maxsize= 0, bwmaxsize= 0;
+ short foundwin= 0;
+
+ for(sa= sc->areabase.first; sa; sa= sa->next) {
+ if(sa->winx > 30 && sa->winy > 30) {
+ size= sa->winx*sa->winy;
+ if(sa->spacetype == SPACE_BUTS) {
+ if(foundwin == 0 && size > bwmaxsize) {
+ bwmaxsize= size;
+ big= sa;
+ }
+ }
+ else if(sa->spacetype != SPACE_IMAGE && size > maxsize) {
+ maxsize= size;
+ big= sa;
+ foundwin= 1;
+ }
+ }
+ }
+
+ return big;
+}
+
+static ScrArea *biggest_area(bContext *C)
+{
+ bScreen *sc= CTX_wm_screen(C);
+ ScrArea *sa, *big= NULL;
+ int size, maxsize= 0;
+
+ for(sa= sc->areabase.first; sa; sa= sa->next) {
+ size= sa->winx*sa->winy;
+ if(size > maxsize) {
+ maxsize= size;
+ big= sa;
+ }
+ }
+ return big;
+}
+
+static ScrArea *find_area_showing_r_result(bContext *C, wmWindow **win)
+{
+ wmWindowManager *wm= CTX_wm_manager(C);
+ ScrArea *sa = NULL;
+ SpaceImage *sima;
+
+ /* find an imagewindow showing render result */
+ for(*win=wm->windows.first; *win; *win= (*win)->next) {
+ for(sa= (*win)->screen->areabase.first; sa; sa= sa->next) {
+ if(sa->spacetype==SPACE_IMAGE) {
+ sima= sa->spacedata.first;
+ if(sima->image && sima->image->type==IMA_TYPE_R_RESULT)
+ break;
+ }
+ }
+ if(sa)
+ break;
+ }
+
+ return sa;
+}
+
+static ScrArea *find_area_image_empty(bContext *C)
+{
+ bScreen *sc= CTX_wm_screen(C);
+ ScrArea *sa;
+ SpaceImage *sima;
+
+ /* find an imagewindow showing render result */
+ for(sa=sc->areabase.first; sa; sa= sa->next) {
+ if(sa->spacetype==SPACE_IMAGE) {
+ sima= sa->spacedata.first;
+ if(!sima->image)
+ break;
+ }
+ }
+
+ return sa;
+}
+
+/********************** open image editor for render *************************/
+
+/* new window uses x,y to set position */
+void render_view_open(bContext *C, int mx, int my)
+{
+ wmWindow *win= CTX_wm_window(C);
+ Scene *scene= CTX_data_scene(C);
+ ScrArea *sa= NULL;
+ SpaceImage *sima;
+ int area_was_image=0;
+
+ if(scene->r.displaymode==R_OUTPUT_NONE)
+ return;
+
+ if(scene->r.displaymode==R_OUTPUT_WINDOW) {
+ rcti rect;
+ int sizex, sizey;
+
+ sizex= 10 + (scene->r.xsch*scene->r.size)/100;
+ sizey= 40 + (scene->r.ysch*scene->r.size)/100;
+
+ /* arbitrary... miniature image window views don't make much sense */
+ if(sizex < 320) sizex= 320;
+ if(sizey < 256) sizey= 256;
+
+ /* XXX some magic to calculate postition */
+ rect.xmin= mx + win->posx - sizex/2;
+ rect.ymin= my + win->posy - sizey/2;
+ rect.xmax= rect.xmin + sizex;
+ rect.ymax= rect.ymin + sizey;
+
+ /* changes context! */
+ WM_window_open_temp(C, &rect, WM_WINDOW_RENDER);
+
+ sa= CTX_wm_area(C);
+ }
+ else if(scene->r.displaymode==R_OUTPUT_SCREEN) {
+ if (CTX_wm_area(C) && CTX_wm_area(C)->spacetype == SPACE_IMAGE)
+ area_was_image = 1;
+
+ /* this function returns with changed context */
+ ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE);
+ sa= CTX_wm_area(C);
+ }
+
+ if(!sa) {
+ sa= find_area_showing_r_result(C, &win);
+ if(sa==NULL)
+ sa= find_area_image_empty(C);
+
+ /* if area found in other window, we make that one show in front */
+ if(win && win!=CTX_wm_window(C))
+ wm_window_raise(win);
+
+ if(sa==NULL) {
+ /* find largest open non-image area */
+ sa= biggest_non_image_area(C);
+ if(sa) {
+ ED_area_newspace(C, sa, SPACE_IMAGE);
+ sima= sa->spacedata.first;
+
+ /* makes ESC go back to prev space */
+ sima->flag |= SI_PREVSPACE;
+ }
+ else {
+ /* use any area of decent size */
+ sa= biggest_area(C);
+ if(sa->spacetype!=SPACE_IMAGE) {
+ // XXX newspace(sa, SPACE_IMAGE);
+ sima= sa->spacedata.first;
+
+ /* makes ESC go back to prev space */
+ sima->flag |= SI_PREVSPACE;
+ }
+ }
+ }
+ }
+ sima= sa->spacedata.first;
+
+ /* get the correct image, and scale it */
+ sima->image= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
+
+
+ /* if we're rendering to full screen, set appropriate hints on image editor
+ * so it can restore properly on pressing esc */
+ if(sa->full) {
+ sima->flag |= SI_FULLWINDOW;
+
+ /* Tell the image editor to revert to previous space in space list on close
+ * _only_ if it wasn't already an image editor when the render was invoked */
+ if (area_was_image == 0)
+ sima->flag |= SI_PREVSPACE;
+ else {
+ /* Leave it alone so the image editor will just go back from
+ * full screen to the original tiled setup */
+ ;
+ }
+ }
+}
+
+/*************************** cancel render viewer **********************/
+
+static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ wmWindow *win= CTX_wm_window(C);
+ ScrArea *sa= CTX_wm_area(C);
+ SpaceImage *sima= sa->spacedata.first;
+
+ /* test if we have a temp screen in front */
+ if(CTX_wm_window(C)->screen->temp) {
+ wm_window_lower(CTX_wm_window(C));
+ return OPERATOR_FINISHED;
+ }
+ /* determine if render already shows */
+ else if(sima->flag & SI_PREVSPACE) {
+ sima->flag &= ~SI_PREVSPACE;
+
+ if(sima->flag & SI_FULLWINDOW) {
+ sima->flag &= ~SI_FULLWINDOW;
+ ED_screen_full_prevspace(C, sa);
+ }
+ else
+ ED_area_prevspace(C, sa);
+
+ return OPERATOR_FINISHED;
+ }
+ else if(sima->flag & SI_FULLWINDOW) {
+ sima->flag &= ~SI_FULLWINDOW;
+ ED_screen_full_toggle(C, win, sa);
+ return OPERATOR_FINISHED;
+ }
+
+ return OPERATOR_PASS_THROUGH;
+}
+
+void RENDER_OT_view_cancel(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Cancel Render View";
+ ot->description= "Cancel show render view";
+ ot->idname= "RENDER_OT_view_cancel";
+
+ /* api callbacks */
+ ot->exec= render_view_cancel_exec;
+ ot->poll= ED_operator_image_active;
+}
+
+/************************* show render viewer *****************/
+
+static int render_view_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
+{
+ wmWindow *wincur = CTX_wm_window(C);
+
+ /* test if we have currently a temp screen active */
+ if(wincur->screen->temp) {
+ wm_window_lower(wincur);
+ }
+ else {
+ wmWindow *win, *winshow;
+ ScrArea *sa= find_area_showing_r_result(C, &winshow);
+
+ /* is there another window showing result? */
+ for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
+ if(win->screen->temp || (win==winshow && winshow!=wincur)) {
+ wm_window_raise(win);
+ return OPERATOR_FINISHED;
+ }
+ }
+
+ /* determine if render already shows */
+ if(sa) {
+ /* but don't close it when rendering */
+ if(!G.rendering) {
+ SpaceImage *sima= sa->spacedata.first;
+
+ if(sima->flag & SI_PREVSPACE) {
+ sima->flag &= ~SI_PREVSPACE;
+
+ if(sima->flag & SI_FULLWINDOW) {
+ sima->flag &= ~SI_FULLWINDOW;
+ ED_screen_full_prevspace(C, sa);
+ }
+ else if(sima->next) {
+ /* workaround for case of double prevspace, render window
+ with a file browser on top of it (same as in ED_area_prevspace) */
+ if(sima->next->spacetype == SPACE_FILE && sima->next->next)
+ ED_area_newspace(C, sa, sima->next->next->spacetype);
+ else
+ ED_area_newspace(C, sa, sima->next->spacetype);
+ ED_area_tag_redraw(sa);
+ }
+ }
+ }
+ }
+ else {
+ render_view_open(C, event->x, event->y);
+ }
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void RENDER_OT_view_show(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Show/Hide Render View";
+ ot->description= "Toggle show render view";
+ ot->idname= "RENDER_OT_view_show";
+
+ /* api callbacks */
+ ot->invoke= render_view_show_invoke;
+ ot->poll= ED_operator_screenactive;
+}
+
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 1882d849116..a1a4f33d008 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -873,12 +873,10 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand
if(sa->spacetype!=SPACE_TIME) {
ARegion *ar;
static rcti rect= {0, 10000, 0, 30}; /* same local check for all areas */
-
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype == RGN_TYPE_WINDOW)
- break;
- if(ar)
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if(ar) {
WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct);
+ }
}
else
WM_event_add_keymap_handler(handlers, keymap);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index b7622565c24..7706a607e70 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -2614,13 +2614,8 @@ static int header_flip_exec(bContext *C, wmOperator *UNUSED(op))
*/
if((ar == NULL) || (ar->regiontype != RGN_TYPE_HEADER)) {
ScrArea *sa= CTX_wm_area(C);
-
- /* loop over all regions until a matching one is found */
- for (ar= sa->regionbase.first; ar; ar= ar->next) {
- if(ar->regiontype == RGN_TYPE_HEADER)
- break;
- }
-
+ ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+
/* don't do anything if no region */
if(ar == NULL)
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index ba21a09cab2..3010adafe20 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -72,41 +72,6 @@ typedef struct ScreenshotData {
int dumpsx, dumpsy;
} ScreenshotData;
-static int screenshot_exec(bContext *C, wmOperator *op)
-{
- ScreenshotData *scd= op->customdata;
-
- if(scd) {
- if(scd->dumprect) {
- Scene *scene= CTX_data_scene(C);
- ImBuf *ibuf;
- char path[FILE_MAX];
-
- RNA_string_get(op->ptr, "filepath", path);
-
- strcpy(G.ima, path);
- BLI_path_abs(path, G.main->name);
-
- /* BKE_add_image_extension() checks for if extension was already set */
- if(scene->r.scemode & R_EXTENSION)
- if(strlen(path)<FILE_MAXDIR+FILE_MAXFILE-5)
- BKE_add_image_extension(path, scene->r.imtype);
-
- ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0);
- ibuf->rect= scd->dumprect;
-
- BKE_write_ibuf(ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality);
-
- IMB_freeImBuf(ibuf);
-
- MEM_freeN(scd->dumprect);
- }
- MEM_freeN(scd);
- op->customdata= NULL;
- }
- return OPERATOR_FINISHED;
-}
-
/* get shot from frontbuffer */
static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy, int fscreen)
{
@@ -140,8 +105,8 @@ static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy, int fscre
return dumprect;
}
-
-static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+/* call from both exec and invoke */
+static int screenshot_data_create(bContext *C, wmOperator *op)
{
unsigned int *dumprect;
int dumpsx, dumpsy;
@@ -154,7 +119,68 @@ static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
scd->dumpsy= dumpsy;
scd->dumprect= dumprect;
op->customdata= scd;
-
+ return TRUE;
+ }
+ else {
+ op->customdata= NULL;
+ return FALSE;
+ }
+}
+
+static void screenshot_data_free(wmOperator *op)
+{
+ ScreenshotData *scd= op->customdata;
+
+ if(scd) {
+ if(scd->dumprect)
+ MEM_freeN(scd->dumprect);
+ MEM_freeN(scd);
+ op->customdata= NULL;
+ }
+}
+
+static int screenshot_exec(bContext *C, wmOperator *op)
+{
+ ScreenshotData *scd= op->customdata;
+
+ if(scd == NULL) {
+ /* when running exec directly */
+ screenshot_data_create(C, op);
+ scd= op->customdata;
+ }
+
+ if(scd) {
+ if(scd->dumprect) {
+ Scene *scene= CTX_data_scene(C);
+ ImBuf *ibuf;
+ char path[FILE_MAX];
+
+ RNA_string_get(op->ptr, "filepath", path);
+
+ strcpy(G.ima, path);
+ BLI_path_abs(path, G.main->name);
+
+ /* BKE_add_image_extension() checks for if extension was already set */
+ if(scene->r.scemode & R_EXTENSION)
+ if(strlen(path)<FILE_MAXDIR+FILE_MAXFILE-5)
+ BKE_add_image_extension(path, scene->r.imtype);
+
+ ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0);
+ ibuf->rect= scd->dumprect;
+
+ BKE_write_ibuf(ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality);
+
+ IMB_freeImBuf(ibuf);
+ }
+ }
+
+ screenshot_data_free(op);
+ return OPERATOR_FINISHED;
+}
+
+static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+{
+ if(screenshot_data_create(C, op)) {
if(RNA_property_is_set(op->ptr, "filepath"))
return screenshot_exec(C, op);
@@ -169,14 +195,7 @@ static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
static int screenshot_cancel(bContext *UNUSED(C), wmOperator *op)
{
- ScreenshotData *scd= op->customdata;
-
- if(scd) {
- if(scd->dumprect)
- MEM_freeN(scd->dumprect);
- MEM_freeN(scd);
- op->customdata= NULL;
- }
+ screenshot_data_free(op);
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 72353ce124d..2080ac3609f 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -3979,7 +3979,7 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), float *lastpos, f
}
-static int project_paint_sub_stroke(ProjPaintState *ps, BrushPainter *painter, int *UNUSED(prevmval_i), int *mval_i, double time, float pressure)
+static int project_paint_sub_stroke(ProjPaintState *ps, BrushPainter *painter, const int UNUSED(prevmval_i[2]), const int mval_i[2], double time, float pressure)
{
/* Use mouse coords as floats for projection painting */
@@ -3998,7 +3998,7 @@ static int project_paint_sub_stroke(ProjPaintState *ps, BrushPainter *painter, i
}
-static int project_paint_stroke(ProjPaintState *ps, BrushPainter *painter, int *prevmval_i, int *mval_i, double time, float pressure)
+static int project_paint_stroke(ProjPaintState *ps, BrushPainter *painter, const int prevmval_i[2], const int mval_i[2], double time, float pressure)
{
int a, redraw;
@@ -4421,7 +4421,7 @@ static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter,
else return 0;
}
-static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPainter *painter, short texpaint, int *prevmval, int *mval, double time, float pressure)
+static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPainter *painter, short texpaint, const int prevmval[2], const int mval[2], double time, float pressure)
{
Image *newimage = NULL;
float fwuv[2], bkuv[2], newuv[2];
@@ -4882,7 +4882,6 @@ static int paint_exec(bContext *C, wmOperator *op)
static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event)
{
- ARegion *ar= CTX_wm_region(C);
PaintOperation *pop= op->customdata;
wmTabletData *wmtab;
PointerRNA itemptr;
@@ -4892,8 +4891,8 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event)
// XXX +1 matches brush location better but
// still not exact, find out why and fix ..
- mouse[0]= event->x - ar->winrct.xmin + 1;
- mouse[1]= event->y - ar->winrct.ymin + 1;
+ mouse[0]= event->mval[0] + 1;
+ mouse[1]= event->mval[1] + 1;
time= PIL_check_seconds_timer();
@@ -5209,16 +5208,8 @@ static int sample_color_exec(bContext *C, wmOperator *op)
static int sample_color_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- ARegion *ar= CTX_wm_region(C);
- int location[2];
-
- if(ar) {
- location[0]= event->x - ar->winrct.xmin;
- location[1]= event->y - ar->winrct.ymin;
- RNA_int_set_array(op->ptr, "location", location);
-
- sample_color_exec(C, op);
- }
+ RNA_int_set_array(op->ptr, "location", event->mval);
+ sample_color_exec(C, op);
WM_event_add_modal_handler(C, op);
@@ -5227,21 +5218,13 @@ static int sample_color_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int sample_color_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- ARegion *ar= CTX_wm_region(C);
- int location[2];
-
switch(event->type) {
case LEFTMOUSE:
case RIGHTMOUSE: // XXX hardcoded
return OPERATOR_FINISHED;
case MOUSEMOVE:
- if(ar) {
- location[0]= event->x - ar->winrct.xmin;
- location[1]= event->y - ar->winrct.ymin;
- RNA_int_set_array(op->ptr, "location", location);
-
- sample_color_exec(C, op);
- }
+ RNA_int_set_array(op->ptr, "location", event->mval);
+ sample_color_exec(C, op);
break;
}
@@ -5308,14 +5291,10 @@ static int set_clone_cursor_invoke(bContext *C, wmOperator *op, wmEvent *event)
View3D *v3d= CTX_wm_view3d(C);
ARegion *ar= CTX_wm_region(C);
float location[3];
- int mval[2];
-
- mval[0]= event->x - ar->winrct.xmin;
- mval[1]= event->y - ar->winrct.ymin;
view3d_operator_needs_opengl(C);
- if(!view_autodist(scene, ar, v3d, mval, location))
+ if(!ED_view3d_autodist(scene, ar, v3d, event->mval, location))
return OPERATOR_CANCELLED;
RNA_float_set_array(op->ptr, "location", location);
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index ba7235a3161..b024f22e8dd 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -106,8 +106,8 @@ void PAINT_OT_image_from_view(struct wmOperatorType *ot);
void projectf(struct bglMats *mats, const float v[3], float p[2]);
float paint_calc_object_space_radius(struct ViewContext *vc, float center[3], float pixel_radius);
float paint_get_tex_pixel(struct Brush* br, float u, float v);
-int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsigned int *index);
-void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, int *xy, float *uv);
+int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, const int mval[2], unsigned int *index);
+void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);
void paint_sample_color(struct Scene *scene, struct ARegion *ar, int x, int y);
void BRUSH_OT_curve_preset(struct wmOperatorType *ot);
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index e7b62505417..58c3446673c 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -333,7 +333,7 @@ static int project_brush_radius(RegionView3D* rv3d, float radius, float location
{
float view[3], nonortho[3], ortho[3], offset[3], p1[2], p2[2];
- viewvector(rv3d, location, view);
+ ED_view3d_global_to_vector(rv3d, location, view);
// create a vector that is not orthogonal to view
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 1a672355e0e..4f2cd0160d1 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -58,11 +58,15 @@ float paint_calc_object_space_radius(ViewContext *vc, float center[3],
{
Object *ob = vc->obact;
float delta[3], scale, loc[3];
+ float mval_f[2];
mul_v3_m4v3(loc, ob->obmat, center);
initgrabz(vc->rv3d, loc[0], loc[1], loc[2]);
- window_to_3d_delta(vc->ar, delta, pixel_radius, 0);
+
+ mval_f[0]= pixel_radius;
+ mval_f[1]= 0.0f;
+ ED_view3d_win_to_delta(vc->ar, mval_f, delta);
scale= fabsf(mat4_to_scale(ob->obmat));
scale= (scale == 0.0f)? 1.0f: scale;
@@ -144,7 +148,7 @@ static void imapaint_tri_weights(Object *ob, float *v1, float *v2, float *v3, fl
}
/* compute uv coordinates of mouse in face */
-void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, int *xy, float *uv)
+void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2])
{
DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
const int *index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
@@ -210,7 +214,7 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, int *xy,
}
///* returns 0 if not found, otherwise 1 */
-int imapaint_pick_face(ViewContext *vc, Mesh *me, int *mval, unsigned int *index)
+int imapaint_pick_face(ViewContext *vc, Mesh *me, const int mval[2], unsigned int *index)
{
if(!me || me->totface==0)
return 0;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 2d74b7b382e..a143456c223 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -805,7 +805,7 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x
return tot;
}
-static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, float *mval, float pressure)
+static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, const float mval[2], float pressure)
{
Brush *brush = paint_brush(&vp->paint);
float fac, fac_2, size, dx, dy;
@@ -1810,7 +1810,7 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent
}
#if 0
-static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, int index, float mval[2], float pressure, int UNUSED(flip))
+static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, int index, const float mval[2], float pressure, int UNUSED(flip))
{
ViewContext *vc = &vpd->vc;
Brush *brush = paint_brush(&vp->paint);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 092dfe0752e..1da54684b5f 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -932,7 +932,7 @@ static void calc_sculpt_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **n
{
switch (brush->sculpt_plane) {
case SCULPT_DISP_DIR_VIEW:
- viewvector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
+ ED_view3d_global_to_vector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
break;
case SCULPT_DISP_DIR_X:
@@ -1843,7 +1843,7 @@ static void calc_sculpt_plane(Sculpt *sd, Object *ob, PBVHNode **nodes, int totn
{
switch (brush->sculpt_plane) {
case SCULPT_DISP_DIR_VIEW:
- viewvector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
+ ED_view3d_global_to_vector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
break;
case SCULPT_DISP_DIR_X:
@@ -2952,7 +2952,7 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio
cache->mats = MEM_callocN(sizeof(bglMats), "sculpt bglMats");
view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, cache->mats);
- viewvector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal);
+ ED_view3d_global_to_vector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal);
/* Initialize layer brush displacements and persistent coords */
if(brush->sculpt_tool == SCULPT_TOOL_LAYER) {
/* not supported yet for multires */
@@ -3020,8 +3020,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
cache->orig_grab_location[1],
cache->orig_grab_location[2]);
- window_to_3d_delta(cache->vc->ar, grab_location,
- cache->mouse[0], cache->mouse[1]);
+ ED_view3d_win_to_delta(cache->vc->ar, cache->mouse, grab_location);
/* compute delta to move verts by */
if(!cache->first_time) {
@@ -3273,7 +3272,7 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou
sculpt_stroke_modifiers_check(C, ob);
- viewline(vc->ar, vc->v3d, mval, ray_start, ray_end);
+ ED_view3d_win_to_segment_clip(vc->ar, vc->v3d, mval, ray_start, ray_end);
invert_m4_m4(obimat, ob->obmat);
mul_m4_v3(obimat, ray_start);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 6637e7004d5..be8547afa23 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -847,16 +847,10 @@ static int actkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent
Scene *scene= ac.scene;
ARegion *ar= ac.ar;
View2D *v2d= &ar->v2d;
-
- int mval[2];
float x;
-
- /* get mouse coordinates (in region coordinates) */
- mval[0]= (event->x - ar->winrct.xmin);
- mval[1]= (event->y - ar->winrct.ymin);
-
+
/* determine which side of the current frame mouse is on */
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, NULL);
+ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL);
if (x < CFRA)
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT);
else
@@ -974,7 +968,7 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se
/* ------------------- */
-static void mouse_action_keys (bAnimContext *ac, int mval[2], short select_mode, short column)
+static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select_mode, short column)
{
ListBase anim_data = {NULL, NULL};
DLRBT_Tree anim_keys;
@@ -1159,7 +1153,6 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even
bAnimContext ac;
ARegion *ar;
short selectmode, column;
- int mval[2];
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -1167,11 +1160,7 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even
/* get useful pointers from animation context data */
ar= ac.ar;
-
- /* get mouse coordinates (in region coordinates) */
- mval[0]= (event->x - ar->winrct.xmin);
- mval[1]= (event->y - ar->winrct.ymin);
-
+
/* select mode is either replace (deselect all, then add) or add/extend */
if (RNA_boolean_get(op->ptr, "extend"))
selectmode= SELECT_INVERT;
@@ -1182,7 +1171,7 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even
column= RNA_boolean_get(op->ptr, "column");
/* select keyframe(s) based upon mouse position*/
- mouse_action_keys(&ac, mval, selectmode, column);
+ mouse_action_keys(&ac, event->mval, selectmode, column);
/* set notifier that keyframe selection (and channels too) have changed */
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL);
diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c
index dc588f08ff1..8d48836704e 100644
--- a/source/blender/editors/space_buttons/buttons_header.c
+++ b/source/blender/editors/space_buttons/buttons_header.c
@@ -98,11 +98,13 @@ static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event)
sbuts->mainbuser= sbuts->mainb;
}
+#define BUT_UNIT_X (UI_UNIT_X+2)
+
void buttons_header_buttons(const bContext *C, ARegion *ar)
{
SpaceButs *sbuts= CTX_wm_space_buts(C);
uiBlock *block;
- int xco, yco= 3;
+ int xco, yco= 1;
buttons_context_compute(C, sbuts);
@@ -118,32 +120,32 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
// Default panels
uiBlockBeginAlign(block);
if(sbuts->pathflag & (1<<BCONTEXT_RENDER))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_SCENE, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_RENDER, 0, 0, "Render");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_SCENE, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_RENDER, 0, 0, "Render");
if(sbuts->pathflag & (1<<BCONTEXT_SCENE))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_SCENE_DATA, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_SCENE, 0, 0, "Scene");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_SCENE_DATA, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_SCENE, 0, 0, "Scene");
if(sbuts->pathflag & (1<<BCONTEXT_WORLD))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_WORLD, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_WORLD, 0, 0, "World");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_WORLD, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_WORLD, 0, 0, "World");
if(sbuts->pathflag & (1<<BCONTEXT_OBJECT))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_OBJECT_DATA, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_OBJECT, 0, 0, "Object");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_OBJECT_DATA, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_OBJECT, 0, 0, "Object");
if(sbuts->pathflag & (1<<BCONTEXT_CONSTRAINT))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Object Constraints");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Object Constraints");
if(sbuts->pathflag & (1<<BCONTEXT_MODIFIER))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MODIFIER, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_MODIFIER, 0, 0, "Modifiers");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MODIFIER, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_MODIFIER, 0, 0, "Modifiers");
if(sbuts->pathflag & (1<<BCONTEXT_DATA))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, sbuts->dataicon, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_DATA, 0, 0, "Object Data");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, sbuts->dataicon, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_DATA, 0, 0, "Object Data");
if(sbuts->pathflag & (1<<BCONTEXT_BONE))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_BONE_DATA, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE, 0, 0, "Bone");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_BONE_DATA, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE, 0, 0, "Bone");
if(sbuts->pathflag & (1<<BCONTEXT_BONE_CONSTRAINT))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT_BONE, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE_CONSTRAINT, 0, 0, "Bone Constraints");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT_BONE, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE_CONSTRAINT, 0, 0, "Bone Constraints");
if(sbuts->pathflag & (1<<BCONTEXT_MATERIAL))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MATERIAL, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_MATERIAL, 0, 0, "Material");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MATERIAL, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_MATERIAL, 0, 0, "Material");
if(sbuts->pathflag & (1<<BCONTEXT_TEXTURE))
- uiDefIconButS(block, ROW, B_BUTSPREVIEW, ICON_TEXTURE, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_TEXTURE, 0, 0, "Texture");
+ uiDefIconButS(block, ROW, B_BUTSPREVIEW, ICON_TEXTURE, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_TEXTURE, 0, 0, "Texture");
if(sbuts->pathflag & (1<<BCONTEXT_PARTICLE))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_PARTICLES, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_PARTICLE, 0, 0, "Particles");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_PARTICLES, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_PARTICLE, 0, 0, "Particles");
if(sbuts->pathflag & (1<<BCONTEXT_PHYSICS))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_PHYSICS, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_PHYSICS, 0, 0, "Physics");
- xco+= BUTS_UI_UNIT;
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_PHYSICS, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_PHYSICS, 0, 0, "Physics");
+ xco+= BUT_UNIT_X;
uiBlockEndAlign(block);
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index d92488e47ef..925223b43ea 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -55,9 +55,6 @@ struct ID;
#define BUTS_SENS_STATE 512
#define BUTS_ACT_STATE 1024
-#define BUTS_HEADERY (HEADERY*1.2)
-#define BUTS_UI_UNIT (UI_UNIT_Y*1.2)
-
/* internal exports only */
/* buttons_header.c */
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index a808e9885c4..16c4df59420 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -405,7 +405,7 @@ void ED_spacetype_buttons(void)
/* regions: header */
art= MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
art->regionid = RGN_TYPE_HEADER;
- art->prefsizey= BUTS_HEADERY;
+ art->prefsizey= HEADERY;
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER;
art->init= buttons_header_area_init;
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 5d786c1d00b..9662b4b401f 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -318,8 +318,8 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
if(ar->regiontype != RGN_TYPE_WINDOW)
return OPERATOR_CANCELLED;
- rect.xmin = rect.xmax = event->x - ar->winrct.xmin;
- rect.ymin = rect.ymax = event->y - ar->winrct.ymin;
+ rect.xmin = rect.xmax = event->mval[0];
+ rect.ymin = rect.ymax = event->mval[1];
if(!BLI_in_rcti(&ar->v2d.mask, rect.xmin, rect.ymin))
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 155c19f0763..9b65589ef4c 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -59,6 +59,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_library.h"
+#include "BKE_icons.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "BLO_readfile.h"
@@ -433,7 +434,7 @@ void folderlist_pushdir(ListBase* folderlist, const char *dir)
// check if already exists
if(previous_folder && previous_folder->foldername){
- if(! strcmp(previous_folder->foldername, dir)){
+ if(BLI_path_cmp(previous_folder->foldername, dir)==0){
return;
}
}
@@ -999,7 +1000,7 @@ static int groupname_to_code(char *group)
return BKE_idcode_from_name(buf);
}
-
+
void filelist_from_library(struct FileList* filelist)
{
LinkNode *l, *names, *previews;
@@ -1086,7 +1087,7 @@ void filelist_from_library(struct FileList* filelist)
}
BLI_linklist_free(names, free);
- if (previews) BLI_linklist_free(previews, (void(*)(void*)) MEM_freeN);
+ if (previews) BLI_linklist_free(previews, BKE_previewimg_freefunc);
filelist_sort(filelist, FILE_SORT_ALPHA);
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index d3b9c68a492..382bb71a592 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -320,7 +320,9 @@ static int draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu)
/* don't draw handle lines if handles are not to be shown */
if ( (sipo->flag & SIPO_NOHANDLES) || /* handles shouldn't be shown anywhere */
(fcu->flag & FCURVE_PROTECTED) || /* keyframes aren't editable */
+#if 0 /* handles can still be selected and handle types set, better draw - campbell */
(fcu->flag & FCURVE_INT_VALUES) || /* editing the handles here will cause weird/incorrect interpolation issues */
+#endif
((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) || /* group that curve belongs to is not editable */
(fcu->totvert <= 1) /* do not show handles if there is only 1 keyframe, otherwise they all clump together in an ugly ball */
)
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 8510446768d..03cc8bb9e80 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -102,18 +102,13 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, wmEvent *even
{
ARegion *ar= CTX_wm_region(C);
float viewx, viewy;
- int x, y;
-
+
/* abort if not active region (should not really be possible) */
if (ar == NULL)
return;
-
- /* convert screen coordinates to region coordinates */
- x= event->x - ar->winrct.xmin;
- y= event->y - ar->winrct.ymin;
-
+
/* convert from region coordinates to View2D 'tot' space */
- UI_view2d_region_to_view(&ar->v2d, x, y, &viewx, &viewy);
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy);
/* store the values in the operator properties */
/* frame is rounded to the nearest int, since frames are ints */
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 47b3a71a9ea..daae0ad6625 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -817,16 +817,10 @@ static int graphkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEve
Scene *scene= ac.scene;
ARegion *ar= ac.ar;
View2D *v2d= &ar->v2d;
-
- int mval[2];
float x;
-
- /* get mouse coordinates (in region coordinates) */
- mval[0]= (event->x - ar->winrct.xmin);
- mval[1]= (event->y - ar->winrct.ymin);
-
+
/* determine which side of the current frame mouse is on */
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, NULL);
+ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL);
if (x < CFRA)
RNA_int_set(op->ptr, "mode", GRAPHKEYS_LRSEL_LEFT);
else
@@ -905,7 +899,7 @@ static int fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt)
/* check if the given vertex is within bounds or not */
// TODO: should we return if we hit something?
-static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, int mval[2])
+static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2])
{
/* Keyframes or Samples? */
if (bezt) {
@@ -957,7 +951,7 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f
}
/* helper for find_nearest_fcurve_vert() - build the list of nearest matches */
-static void get_nearest_fcurve_verts_list (bAnimContext *ac, int mval[2], ListBase *matches)
+static void get_nearest_fcurve_verts_list (bAnimContext *ac, const int mval[2], ListBase *matches)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
@@ -1074,7 +1068,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches)
/* Find the nearest vertices (either a handle or the keyframe) that are nearest to the mouse cursor (in area coordinates)
* NOTE: the match info found must still be freed
*/
-static tNearestVertInfo *find_nearest_fcurve_vert (bAnimContext *ac, int mval[2])
+static tNearestVertInfo *find_nearest_fcurve_vert (bAnimContext *ac, const int mval[2])
{
ListBase matches = {NULL, NULL};
tNearestVertInfo *nvi;
@@ -1094,7 +1088,7 @@ static tNearestVertInfo *find_nearest_fcurve_vert (bAnimContext *ac, int mval[2]
/* ------------------- */
/* option 1) select keyframe directly under mouse */
-static void mouse_graph_keys (bAnimContext *ac, int mval[], short select_mode, short curves_only)
+static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_mode, short curves_only)
{
SpaceIpo *sipo= (SpaceIpo *)ac->sa->spacedata.first;
tNearestVertInfo *nvi;
@@ -1217,7 +1211,7 @@ static void mouse_graph_keys (bAnimContext *ac, int mval[], short select_mode, s
/* (see graphkeys_select_leftright) */
/* Option 3) Selects all visible keyframes in the same frame as the mouse click */
-static void graphkeys_mselect_column (bAnimContext *ac, int mval[2], short select_mode)
+static void graphkeys_mselect_column (bAnimContext *ac, const int mval[2], short select_mode)
{
ListBase anim_data= {NULL, NULL};
bAnimListElem *ale;
@@ -1299,19 +1293,14 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *ev
bAnimContext ac;
ARegion *ar;
short selectmode;
- int mval[2];
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
/* get useful pointers from animation context data */
ar= ac.ar;
-
- /* get mouse coordinates (in region coordinates) */
- mval[0]= (event->x - ar->winrct.xmin);
- mval[1]= (event->y - ar->winrct.ymin);
-
+
/* select mode is either replace (deselect all, then add) or add/extend */
if (RNA_boolean_get(op->ptr, "extend"))
selectmode= SELECT_INVERT;
@@ -1321,15 +1310,15 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *ev
/* figure out action to take */
if (RNA_boolean_get(op->ptr, "column")) {
/* select all keyframes in the same frame as the one that was under the mouse */
- graphkeys_mselect_column(&ac, mval, selectmode);
+ graphkeys_mselect_column(&ac, event->mval, selectmode);
}
else if (RNA_boolean_get(op->ptr, "curves")) {
/* select all keyframes in the same F-Curve as the one under the mouse */
- mouse_graph_keys(&ac, mval, selectmode, 1);
+ mouse_graph_keys(&ac, event->mval, selectmode, 1);
}
else {
/* select keyframe under mouse */
- mouse_graph_keys(&ac, mval, selectmode, 0);
+ mouse_graph_keys(&ac, event->mval, selectmode, 0);
}
/* set notifier that keyframe selection (and also channel selection in some cases) has changed */
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 554d2e36ccf..883b476f372 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -71,17 +71,12 @@ ARegion *graph_has_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;
- for (ar= sa->regionbase.first; ar; ar= ar->next) {
- if (ar->regiontype==RGN_TYPE_UI)
- return ar;
- }
-
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ if(ar) return ar;
+
/* add subdiv level; after main */
- for (ar= sa->regionbase.first; ar; ar= ar->next) {
- if (ar->regiontype==RGN_TYPE_WINDOW)
- break;
- }
-
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+
/* is error! */
if (ar==NULL) return NULL;
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index c4d52e3b836..f48daa39c59 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1653,16 +1653,13 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
ImageSampleInfo *info= op->customdata;
float fx, fy;
- int mx, my;
if(ibuf == NULL) {
ED_space_image_release_buffer(sima, lock);
return;
}
- mx= event->x - ar->winrct.xmin;
- my= event->y - ar->winrct.ymin;
- UI_view2d_region_to_view(&ar->v2d, mx, my, &fx, &fy);
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy);
if(fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) {
float *fp;
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 2165f2faa5d..c74dc950df8 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -326,16 +326,13 @@ static void image_scopes_tag_refresh(ScrArea *sa)
ARegion *image_has_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;
-
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_UI)
- return ar;
+
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ if(ar) return ar;
/* add subdiv level; after header */
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_HEADER)
- break;
-
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+
/* is error! */
if(ar==NULL) return NULL;
@@ -353,16 +350,13 @@ ARegion *image_has_buttons_region(ScrArea *sa)
ARegion *image_has_scope_region(ScrArea *sa)
{
ARegion *ar, *arnew;
-
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_PREVIEW)
- return ar;
-
+
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
+ if(ar) return ar;
+
/* add subdiv level; after buttons */
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_UI)
- break;
-
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
+
/* is error! */
if(ar==NULL) return NULL;
diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c
index 7944f0737e1..f420d0ef690 100644
--- a/source/blender/editors/space_logic/space_logic.c
+++ b/source/blender/editors/space_logic/space_logic.c
@@ -63,16 +63,13 @@
ARegion *logic_has_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;
-
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_UI)
- return ar;
+
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ if(ar) return ar;
/* add subdiv level; after header */
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_HEADER)
- break;
-
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+
/* is error! */
if(ar==NULL) return NULL;
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index 265616020d5..38f680fff07 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -303,7 +303,7 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e
bAnimContext ac;
ARegion *ar;
View2D *v2d;
- int mval[2], channel_index;
+ int channel_index;
int notifierFlags = 0;
short selectmode;
float x, y;
@@ -316,10 +316,6 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e
ar= ac.ar;
v2d= &ar->v2d;
- /* get mouse coordinates (in region coordinates) */
- mval[0]= (event->x - ar->winrct.xmin);
- mval[1]= (event->y - ar->winrct.ymin);
-
/* select mode is either replace (deselect all, then add) or add/extend */
if (RNA_boolean_get(op->ptr, "extend"))
selectmode= SELECT_INVERT;
@@ -331,7 +327,7 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e
* so that the tops of channels get caught ok. Since NLACHANNEL_FIRST is really NLACHANNEL_HEIGHT, we simply use
* NLACHANNEL_HEIGHT_HALF.
*/
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
+ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y);
UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP, 0, (float)NLACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index);
/* handle mouse-click in the relevant channel then */
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index 188042ad1d1..0f0a4c0ad4c 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -459,16 +459,10 @@ static int nlaedit_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent
Scene *scene= ac.scene;
ARegion *ar= ac.ar;
View2D *v2d= &ar->v2d;
-
- int mval[2];
float x;
- /* get mouse coordinates (in region coordinates) */
- mval[0]= (event->x - ar->winrct.xmin);
- mval[1]= (event->y - ar->winrct.ymin);
-
/* determine which side of the current frame mouse is on */
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, NULL);
+ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL);
if (x < CFRA)
RNA_int_set(op->ptr, "mode", NLAEDIT_LRSEL_LEFT);
else
@@ -503,7 +497,7 @@ void NLA_OT_select_leftright (wmOperatorType *ot)
/* ******************** Mouse-Click Select Operator *********************** */
/* select strip directly under mouse */
-static void mouse_nla_strips (bContext *C, bAnimContext *ac, int mval[2], short select_mode)
+static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], short select_mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale = NULL;
@@ -614,8 +608,7 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even
ARegion *ar;
// View2D *v2d; /*UNUSED*/
short selectmode;
- int mval[2];
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
@@ -624,11 +617,7 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even
scene= ac.scene;
ar= ac.ar;
// v2d= &ar->v2d;
-
- /* get mouse coordinates (in region coordinates) */
- mval[0]= (event->x - ar->winrct.xmin);
- mval[1]= (event->y - ar->winrct.ymin);
-
+
/* select mode is either replace (deselect all, then add) or add/extend */
if (RNA_boolean_get(op->ptr, "extend"))
selectmode= SELECT_INVERT;
@@ -636,7 +625,7 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even
selectmode= SELECT_REPLACE;
/* select strips based upon mouse position */
- mouse_nla_strips(C, &ac, mval, selectmode);
+ mouse_nla_strips(C, &ac, event->mval, selectmode);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_SELECTED, NULL);
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 90f9996e392..f2e0abe1e60 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -69,18 +69,13 @@
ARegion *nla_has_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;
-
- for (ar= sa->regionbase.first; ar; ar= ar->next) {
- if (ar->regiontype==RGN_TYPE_UI)
- return ar;
- }
-
+
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ if(ar) return ar;
+
/* add subdiv level; after main */
- for (ar= sa->regionbase.first; ar; ar= ar->next) {
- if (ar->regiontype==RGN_TYPE_WINDOW)
- break;
- }
-
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+
/* is error! */
if (ar==NULL) return NULL;
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 19a9bfb224b..d967e2240e6 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -1166,7 +1166,6 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
Image *ima;
ImBuf *ibuf;
float fx, fy, bufx, bufy;
- int mx, my;
ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock);
@@ -1181,13 +1180,11 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
IMB_rect_from_float(ibuf);
}
- mx= event->x - ar->winrct.xmin;
- my= event->y - ar->winrct.ymin;
/* map the mouse coords to the backdrop image space */
bufx = ibuf->x * snode->zoom;
bufy = ibuf->y * snode->zoom;
- fx = (bufx > 0.0f ? ((float)mx - 0.5f*ar->winx - snode->xof) / bufx + 0.5f : 0.0f);
- fy = (bufy > 0.0f ? ((float)my - 0.5f*ar->winy - snode->yof) / bufy + 0.5f : 0.0f);
+ fx = (bufx > 0.0f ? ((float)event->mval[0] - 0.5f*ar->winx - snode->xof) / bufx + 0.5f : 0.0f);
+ fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f*ar->winy - snode->yof) / bufy + 0.5f : 0.0f);
if(fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) {
float *fp;
@@ -1317,7 +1314,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event)
switch (event->type) {
case MOUSEMOVE:
- UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin,
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
&mx, &my);
if (node) {
@@ -1358,7 +1355,7 @@ static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event)
rctf totr;
/* convert mouse coordinates to v2d space */
- UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin,
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
&snode->mx, &snode->my);
/* rect we're interested in is just the bottom right corner */
@@ -2094,7 +2091,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event)
sock= nldrag->sock;
link= nldrag->link;
- UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin,
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
&snode->mx, &snode->my);
switch (event->type) {
@@ -2244,7 +2241,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event)
bNodeLinkDrag *nldrag= MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
- UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin,
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
&snode->mx, &snode->my);
ED_preview_kill_jobs(C);
@@ -2928,7 +2925,7 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, wmEvent *event)
SpaceNode *snode= CTX_wm_space_node(C);
/* convert mouse coordinates to v2d space */
- UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin,
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
&snode->mx, &snode->my);
if (RNA_property_is_set(op->ptr, "filepath") || RNA_property_is_set(op->ptr, "name"))
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 6bda47e5c8f..a1ef75f3976 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -124,14 +124,8 @@ static int node_select_exec(bContext *C, wmOperator *op)
static int node_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- ARegion *ar= CTX_wm_region(C);
- int mval[2];
-
- mval[0]= event->x - ar->winrct.xmin;
- mval[1]= event->y - ar->winrct.ymin;
-
- RNA_int_set(op->ptr, "mouse_x", mval[0]);
- RNA_int_set(op->ptr, "mouse_y", mval[1]);
+ RNA_int_set(op->ptr, "mouse_x", event->mval[0]);
+ RNA_int_set(op->ptr, "mouse_y", event->mval[1]);
return node_select_exec(C,op);
}
@@ -199,17 +193,9 @@ static int node_border_select_invoke(bContext *C, wmOperator *op, wmEvent *event
/* this allows border select on empty space, but drag-translate on nodes */
SpaceNode *snode= CTX_wm_space_node(C);
ARegion *ar= CTX_wm_region(C);
- int mval[2];
float mx, my;
-
- mval[0]= event->x - ar->winrct.xmin;
- mval[1]= event->y - ar->winrct.ymin;
-
- /* get mouse coordinates in view2d space */
- mx= (float)mval[0];
- my= (float)mval[1];
-
- UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &mx, &my);
+
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my);
if (node_under_mouse(snode->edittree, mx, my))
return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH;
diff --git a/source/blender/editors/space_node/node_state.c b/source/blender/editors/space_node/node_state.c
index 9665a152970..601ffbd313d 100644
--- a/source/blender/editors/space_node/node_state.c
+++ b/source/blender/editors/space_node/node_state.c
@@ -201,14 +201,8 @@ static int node_toggle_visibility_exec(bContext *C, wmOperator *op)
static int node_toggle_visibility_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- ARegion *ar= CTX_wm_region(C);
- int mval[2];
-
- mval[0]= event->x - ar->winrct.xmin;
- mval[1]= event->y - ar->winrct.ymin;
-
- RNA_int_set(op->ptr, "mouse_x", mval[0]);
- RNA_int_set(op->ptr, "mouse_y", mval[1]);
+ RNA_int_set(op->ptr, "mouse_x", event->mval[0]);
+ RNA_int_set(op->ptr, "mouse_y", event->mval[1]);
return node_toggle_visibility_exec(C,op);
}
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 1c2f604a650..96ce19b7601 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -70,16 +70,13 @@
ARegion *node_has_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;
-
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_UI)
- return ar;
+
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ if(ar) return ar;
/* add subdiv level; after header */
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_HEADER)
- break;
-
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+
/* is error! */
if(ar==NULL) return NULL;
diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c
index 32e6424f709..037b1db56d6 100644
--- a/source/blender/editors/space_outliner/outliner.c
+++ b/source/blender/editors/space_outliner/outliner.c
@@ -2482,7 +2482,7 @@ static int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops,
return 0;
}
-static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, float *mval)
+static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, const float mval[2])
{
if(mval[1]>te->ys && mval[1]<te->ys+OL_H) {
@@ -2580,7 +2580,7 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event)
float fmval[2];
int extend= RNA_boolean_get(op->ptr, "extend");
- UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, fmval, fmval+1);
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1);
if(!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && !(soops->flag & SO_HIDE_RESTRICTCOLS) && fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)
return OPERATOR_CANCELLED;
@@ -2628,7 +2628,7 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot)
/* *********** */
-static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, float *mval)
+static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, const float mval[2])
{
if(mval[1]>te->ys && mval[1]<te->ys+OL_H) {
@@ -2664,7 +2664,7 @@ static int outliner_item_openclose(bContext *C, wmOperator *op, wmEvent *event)
float fmval[2];
int all= RNA_boolean_get(op->ptr, "all");
- UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, fmval, fmval+1);
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1);
for(te= soops->tree.first; te; te= te->next) {
if(do_outliner_item_openclose(C, soops, te, all, fmval))
@@ -2693,7 +2693,7 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot)
/* ********************************************** */
-static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, float *mval)
+static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2])
{
if(mval[1]>te->ys && mval[1]<te->ys+OL_H) {
@@ -2736,7 +2736,7 @@ static int outliner_item_rename(bContext *C, wmOperator *UNUSED(op), wmEvent *ev
TreeElement *te;
float fmval[2];
- UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, fmval, fmval+1);
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1);
for(te= soops->tree.first; te; te= te->next) {
if(do_outliner_item_rename(C, ar, soops, te, fmval)) break;
@@ -3728,7 +3728,7 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot)
/* ******************** */
-static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, wmEvent *event, float *mval)
+static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, wmEvent *event, const float mval[2])
{
if(mval[1]>te->ys && mval[1]<te->ys+OL_H) {
@@ -3791,7 +3791,7 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), wmEvent *even
TreeElement *te;
float fmval[2];
- UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, fmval, fmval+1);
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1);
for(te= soops->tree.first; te; te= te->next) {
if(do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) break;
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index ad0d0048388..6d50913dfd4 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -117,17 +117,11 @@ static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op,
static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, wmEvent *event, int flag)
{
- ARegion *ar= CTX_wm_region(C);
View2D *v2d= UI_view2d_fromcontext(C);
- int mval[2];
float mval_v2d[2];
-
- mval[0]= event->x - ar->winrct.xmin;
- mval[1]= event->y - ar->winrct.ymin;
-
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &mval_v2d[0], &mval_v2d[1]);
+ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &mval_v2d[0], &mval_v2d[1]);
RNA_int_set(op->ptr, "channel", (int)mval_v2d[1]+0.5f);
RNA_int_set(op->ptr, "frame_start", (int)mval_v2d[0]);
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 880f285c3e3..4b9f87f67d8 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -1573,14 +1573,13 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op)
static int sequencer_cut_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
Scene *scene = CTX_data_scene(C);
- ARegion *ar= CTX_wm_region(C);
View2D *v2d= UI_view2d_fromcontext(C);
int cut_side= SEQ_SIDE_BOTH;
int cut_frame= CFRA;
if (ED_operator_sequencer_active(C) && v2d)
- cut_side= mouse_frame_side(v2d, event->x - ar->winrct.xmin, cut_frame);
+ cut_side= mouse_frame_side(v2d, event->mval[0], cut_frame);
RNA_int_set(op->ptr, "frame", cut_frame);
RNA_enum_set(op->ptr, "side", cut_side);
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 2cae2d17a33..8440a107f31 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -298,7 +298,6 @@ void SEQUENCER_OT_select_inverse(struct wmOperatorType *ot)
static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- ARegion *ar= CTX_wm_region(C);
View2D *v2d= UI_view2d_fromcontext(C);
Scene *scene= CTX_data_scene(C);
Editing *ed= seq_give_editing(scene, FALSE);
@@ -318,10 +317,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
marker=find_nearest_marker(SCE_MARKERS, 1); //XXX - dummy function for now
- mval[0]= event->x - ar->winrct.xmin;
- mval[1]= event->y - ar->winrct.ymin;
-
- seq= find_nearest_seq(scene, v2d, &hand, mval);
+ seq= find_nearest_seq(scene, v2d, &hand, event->mval);
// XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip
if(seq && linked_time && left_right)
@@ -652,20 +648,15 @@ void SEQUENCER_OT_select_less(wmOperatorType *ot)
static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
Scene *scene= CTX_data_scene(C);
- ARegion *ar= CTX_wm_region(C);
View2D *v2d= UI_view2d_fromcontext(C);
short extend= RNA_boolean_get(op->ptr, "extend");
- int mval[2];
Sequence *mouse_seq;
int selected, hand;
-
- mval[0]= event->x - ar->winrct.xmin;
- mval[1]= event->y - ar->winrct.ymin;
-
+
/* this works like UV, not mesh */
- mouse_seq= find_nearest_seq(scene, v2d, &hand, mval);
+ mouse_seq= find_nearest_seq(scene, v2d, &hand, event->mval);
if (!mouse_seq)
return OPERATOR_FINISHED; /* user error as with mesh?? */
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 32bd9ce604c..d1df9699fa3 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -66,16 +66,13 @@
ARegion *sequencer_has_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;
-
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_UI)
- return ar;
+
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ if(ar) return ar;
/* add subdiv level; after header */
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_HEADER)
- break;
-
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+
/* is error! */
if(ar==NULL) return NULL;
diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c
index bfc600c774a..165cec238c0 100644
--- a/source/blender/editors/space_text/text_header.c
+++ b/source/blender/editors/space_text/text_header.c
@@ -55,6 +55,7 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
+#include "BKE_screen.h"
#include "ED_screen.h"
@@ -78,16 +79,13 @@
static ARegion *text_has_properties_region(ScrArea *sa)
{
ARegion *ar, *arnew;
-
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_UI)
- return ar;
+
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ if(ar) return ar;
/* add subdiv level; after header */
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_HEADER)
- break;
-
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+
/* is error! */
if(ar==NULL) return NULL;
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index ca9d786c4de..e55fbe11e52 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -367,15 +367,11 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar
static void time_refresh(const bContext *UNUSED(C), ScrArea *sa)
{
- SpaceTime *stime = (SpaceTime *)sa->spacedata.first;
- ARegion *ar;
-
/* find the main timeline region and refresh cache display*/
- for (ar= sa->regionbase.first; ar; ar= ar->next) {
- if (ar->regiontype==RGN_TYPE_WINDOW) {
- time_cache_refresh(stime);
- break;
- }
+ ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if(ar) {
+ SpaceTime *stime = (SpaceTime *)sa->spacedata.first;
+ time_cache_refresh(stime);
}
}
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index 1d1c9f10e75..351be1ca4c9 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -369,7 +369,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O
}
else {
/* draw with lights in the scene otherwise */
- Gtexdraw.islit= GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, get_view3d_ortho(v3d, rv3d));
+ Gtexdraw.islit= GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp);
}
obcol[0]= CLAMPIS(ob->col[0]*255, 0, 255);
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index c4eba5e0962..054da3895b5 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -70,16 +70,13 @@
ARegion *view3d_has_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;
-
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_UI)
- return ar;
+
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ if(ar) return ar;
/* add subdiv level; after header */
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_HEADER)
- break;
-
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+
/* is error! */
if(ar==NULL) return NULL;
@@ -147,10 +144,10 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C)
if(rv3d==NULL) {
ScrArea *sa =CTX_wm_area(C);
if(sa && sa->spacetype==SPACE_VIEW3D) {
- ARegion *ar;
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_WINDOW)
- return ar->regiondata;
+ ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if(ar) {
+ rv3d= ar->regiondata;
+ }
}
}
return rv3d;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 4ef02243cd5..adce40f58ce 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -61,6 +61,7 @@
#include "BKE_global.h"
#include "BKE_paint.h"
#include "BKE_scene.h"
+#include "BKE_screen.h"
#include "BKE_unit.h"
#include "RE_pipeline.h" // make_stars
@@ -870,25 +871,15 @@ void view3d_viewborder_size_get(Scene *scene, ARegion *ar, float size_r[2])
void view3d_calc_camera_border(Scene *scene, ARegion *ar, RegionView3D *rv3d, View3D *v3d, rctf *viewborder_r, short do_shift)
{
- float zoomfac, size[2];
+ const float zoomfac= BKE_screen_view3d_zoom_to_fac((float)rv3d->camzoom);
+ float size[2];
float dx= 0.0f, dy= 0.0f;
view3d_viewborder_size_get(scene, ar, size);
if (rv3d == NULL)
rv3d = ar->regiondata;
-
- /* magic zoom calculation, no idea what
- * it signifies, if you find out, tell me! -zr
- */
- /* simple, its magic dude!
- * well, to be honest, this gives a natural feeling zooming
- * with multiple keypad presses (ton)
- */
-
- zoomfac= ((float)M_SQRT2 + rv3d->camzoom/50.0f);
- zoomfac= (zoomfac*zoomfac) * 0.25f;
-
+
size[0]= size[0]*zoomfac;
size[1]= size[1]*zoomfac;
@@ -1416,10 +1407,11 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d)
}
else {
float sco[2];
+ const float mval_f[2]= {1.0f, 0.0f};
/* calc window coord */
initgrabz(rv3d, 0.0, 0.0, 0.0);
- window_to_3d_delta(ar, vec, 1, 0);
+ ED_view3d_win_to_delta(ar, mval_f, vec);
fac= MAX3( fabs(vec[0]), fabs(vec[1]), fabs(vec[1]) );
fac= 1.0f/fac;
@@ -2570,16 +2562,10 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
}
if(v3d->lay_used != lay_used) { /* happens when loading old files or loading with UI load */
- ARegion *ar_iter;
- ScrArea *sa= CTX_wm_area(C);
-
/* find header and force tag redraw */
- for(ar_iter= sa->regionbase.first; ar_iter; ar_iter= ar_iter->next)
- if(ar_iter->regiontype==RGN_TYPE_HEADER) {
- ED_region_tag_redraw(ar_iter);
- break;
- }
-
+ ScrArea *sa= CTX_wm_area(C);
+ ARegion *ar_header= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+ ED_region_tag_redraw(ar_header); /* can be NULL */
v3d->lay_used= lay_used;
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index ee73ed3a0fd..95e845b3462 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -56,6 +56,7 @@
#include "BKE_paint.h"
#include "BKE_report.h"
#include "BKE_scene.h"
+#include "BKE_screen.h"
#include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */
@@ -382,8 +383,8 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event)
view3d_operator_needs_opengl(C); /* needed for zbuf drawing */
- if((vod->use_dyn_ofs=view_autodist(CTX_data_scene(C), vod->ar, vod->v3d, event->mval, vod->dyn_ofs))) {
- if (rv3d->persp==RV3D_PERSP || (rv3d->persp==RV3D_CAMOB && (vod->v3d->flag2 & V3D_LOCK_CAMERA))) {
+ if((vod->use_dyn_ofs=ED_view3d_autodist(CTX_data_scene(C), vod->ar, vod->v3d, event->mval, vod->dyn_ofs))) {
+ if (rv3d->is_persp) {
float my_origin[3]; /* original G.vd->ofs */
float my_pivot[3]; /* view */
float dvec[3];
@@ -417,8 +418,12 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event)
}
}
- /* for dolly */
- window_to_3d_vector(vod->ar, vod->mousevec, vod->oldx - vod->ar->winrct.xmin, vod->oldy - vod->ar->winrct.ymin);
+ {
+ /* for dolly */
+ float mval_f[2];
+ VECCOPY2D(mval_f, event->mval);
+ ED_view3d_win_to_vector(vod->ar, mval_f, vod->mousevec);
+ }
/* lookup, we dont pass on v3d to prevent confusement */
vod->grid= vod->v3d->grid;
@@ -919,19 +924,20 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf)
static void viewmove_apply(ViewOpsData *vod, int x, int y)
{
if((vod->rv3d->persp==RV3D_CAMOB) && !(vod->v3d->flag2 & V3D_LOCK_CAMERA)) {
- float zoomfac= ((float)M_SQRT2 + (float)vod->rv3d->camzoom / 50.0f);
- zoomfac= (zoomfac * zoomfac) * 0.5f;
-
+ const float zoomfac= BKE_screen_view3d_zoom_to_fac((float)vod->rv3d->camzoom) * 2.0f;
vod->rv3d->camdx += (vod->oldx - x)/(vod->ar->winx * zoomfac);
vod->rv3d->camdy += (vod->oldy - y)/(vod->ar->winy * zoomfac);
CLAMP(vod->rv3d->camdx, -1.0f, 1.0f);
CLAMP(vod->rv3d->camdy, -1.0f, 1.0f);
-// XXX preview3d_event= 0;
}
else {
float dvec[3];
+ float mval_f[2];
+
+ mval_f[0]= x - vod->oldx;
+ mval_f[1]= y - vod->oldy;
+ ED_view3d_win_to_delta(vod->ar, mval_f, dvec);
- window_to_3d_delta(vod->ar, dvec, x-vod->oldx, y-vod->oldy);
add_v3_v3(vod->rv3d->ofs, dvec);
if(vod->rv3d->viewlock & RV3D_BOXVIEW)
@@ -1073,8 +1079,9 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my)
float dvec[3];
float tvec[3];
float tpos[3];
+ float mval_f[2];
float new_dist;
- short vb[2], mouseloc[2];
+ int vb[2], mouseloc[2];
mouseloc[0]= mx - ar->winrct.xmin;
mouseloc[1]= my - ar->winrct.ymin;
@@ -1087,7 +1094,10 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my)
/* Project cursor position into 3D space */
initgrabz(rv3d, tpos[0], tpos[1], tpos[2]);
- window_to_3d_delta(ar, dvec, mouseloc[0]-vb[0]/2, mouseloc[1]-vb[1]/2);
+
+ mval_f[0]= (mouseloc[0] - vb[0]) / 2.0f;
+ mval_f[1]= (mouseloc[1] - vb[1]) / 2.0f;
+ ED_view3d_win_to_delta(ar, mval_f, dvec);
/* Calculate view target position for dolly */
add_v3_v3v3(tvec, tpos, dvec);
@@ -1165,24 +1175,9 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom,
zfac * vod->rv3d->dist < 10.0f * vod->far)
view_zoom_mouseloc(vod->ar, zfac, vod->oldx, vod->oldy);
-
- if ((U.uiflag & USER_ORBIT_ZBUF) && (viewzoom==USER_ZOOM_CONT) && (vod->rv3d->persp==RV3D_PERSP)) {
- float upvec[3], mat[3][3];
-
- /* Secret apricot feature, translate the view when in continues mode */
- upvec[0] = upvec[1] = 0.0f;
- upvec[2] = (vod->dist0 - vod->rv3d->dist) * vod->grid;
- vod->rv3d->dist = vod->dist0;
- copy_m3_m4(mat, vod->rv3d->viewinv);
- mul_m3_v3(mat, upvec);
- add_v3_v3(vod->rv3d->ofs, upvec);
- } else {
- /* these limits were in old code too */
- if(vod->rv3d->dist<0.001f * vod->grid) vod->rv3d->dist= 0.001f * vod->grid;
- if(vod->rv3d->dist>10.0f * vod->far) vod->rv3d->dist=10.0f * vod->far;
- }
-
-// XXX if(vod->rv3d->persp==RV3D_ORTHO || vod->rv3d->persp==RV3D_CAMOB) preview3d_event= 0;
+ /* these limits were in old code too */
+ if(vod->rv3d->dist<0.001f * vod->grid) vod->rv3d->dist= 0.001f * vod->grid;
+ if(vod->rv3d->dist>10.0f * vod->far) vod->rv3d->dist=10.0f * vod->far;
if(vod->rv3d->viewlock & RV3D_BOXVIEW)
view3d_boxview_sync(vod->sa, vod->ar);
@@ -1244,6 +1239,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
RegionView3D *rv3d;
ScrArea *sa;
ARegion *ar;
+ short use_cam_zoom;
int delta= RNA_int_get(op->ptr, "delta");
int mx, my;
@@ -1265,9 +1261,11 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
mx= RNA_property_is_set(op->ptr, "mx") ? RNA_int_get(op->ptr, "mx") : ar->winx / 2;
my= RNA_property_is_set(op->ptr, "my") ? RNA_int_get(op->ptr, "my") : ar->winy / 2;
+ use_cam_zoom= (rv3d->persp==RV3D_CAMOB) && !((v3d->flag2 & V3D_LOCK_CAMERA) && rv3d->is_persp);
+
if(delta < 0) {
/* this min and max is also in viewmove() */
- if((rv3d->persp==RV3D_CAMOB) && !(v3d->flag2 & V3D_LOCK_CAMERA)) {
+ if(use_cam_zoom) {
rv3d->camzoom-= 10;
if(rv3d->camzoom < RV3D_CAMZOOM_MIN) rv3d->camzoom= RV3D_CAMZOOM_MIN;
}
@@ -1276,7 +1274,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
}
}
else {
- if((rv3d->persp==RV3D_CAMOB) && !(v3d->flag2 & V3D_LOCK_CAMERA)) {
+ if(use_cam_zoom) {
rv3d->camzoom+= 10;
if(rv3d->camzoom > RV3D_CAMZOOM_MAX) rv3d->camzoom= RV3D_CAMZOOM_MAX;
}
@@ -1791,7 +1789,7 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) /* like a loca
sub_v3_v3v3(afm, max, min);
size= MAX3(afm[0], afm[1], afm[2]);
- if(rv3d->persp==RV3D_ORTHO) {
+ if(!rv3d->is_persp) {
if(size < 0.0001f) { /* if its a sinble point. dont even re-scale */
ok_dist= 0;
}
@@ -1900,8 +1898,8 @@ static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was
xfac= (float)ar->winx / (float)(size[0] + 4);
yfac= (float)ar->winy / (float)(size[1] + 4);
- rv3d->camzoom= (sqrtf(4.0f * MIN2(xfac, yfac)) - (float)M_SQRT2) * 50.0f;
- rv3d->camzoom= CLAMPIS(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX);
+ rv3d->camzoom= BKE_screen_view3d_zoom_from_fac(MIN2(xfac, yfac));
+ CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX);
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C));
@@ -2048,7 +2046,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
cent[0] = (((double)rect.xmin)+((double)rect.xmax)) / 2;
cent[1] = (((double)rect.ymin)+((double)rect.ymax)) / 2;
- if (rv3d->persp==RV3D_PERSP) {
+ if (rv3d->is_persp) {
double p_corner[3];
/* no depths to use, we cant do anything! */
@@ -2084,13 +2082,17 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
new_ofs[0] = -p[0];
new_ofs[1] = -p[1];
new_ofs[2] = -p[2];
- } else {
+ }
+ else {
+ float mval_f[2];
/* We cant use the depth, fallback to the old way that dosnt set the center depth */
copy_v3_v3(new_ofs, rv3d->ofs);
initgrabz(rv3d, -new_ofs[0], -new_ofs[1], -new_ofs[2]);
- window_to_3d_delta(ar, dvec, (rect.xmin+rect.xmax-vb[0])/2, (rect.ymin+rect.ymax-vb[1])/2);
+ mval_f[0]= (rect.xmin + rect.xmax - vb[0]) / 2.0f;
+ mval_f[1]= (rect.ymin + rect.ymax - vb[1]) / 2.0f;
+ ED_view3d_win_to_delta(ar, mval_f, dvec);
/* center the view to the center of the rectangle */
sub_v3_v3(new_ofs, dvec);
}
@@ -2157,9 +2159,9 @@ static void view3d_set_1_to_1_viewborder(Scene *scene, ARegion *ar)
int im_width= (scene->r.size*scene->r.xsch)/100;
view3d_viewborder_size_get(scene, ar, size);
-
- rv3d->camzoom= (sqrtf(4.0f * (float)im_width/size[0]) - (float)M_SQRT2) * 50.0f;
- rv3d->camzoom= CLAMPIS(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX);
+
+ rv3d->camzoom= BKE_screen_view3d_zoom_from_fac((float)im_width/size[0]);
+ CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX);
}
static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op))
@@ -2493,15 +2495,16 @@ static int viewpan_exec(bContext *C, wmOperator *op)
ARegion *ar= CTX_wm_region(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
float vec[3];
+ float mval_f[2]= {0.0f, 0.0f};
int pandir;
pandir = RNA_enum_get(op->ptr, "type");
initgrabz(rv3d, 0.0, 0.0, 0.0);
- if(pandir == V3D_VIEW_PANRIGHT) window_to_3d_delta(ar, vec, -32, 0);
- else if(pandir == V3D_VIEW_PANLEFT) window_to_3d_delta(ar, vec, 32, 0);
- else if(pandir == V3D_VIEW_PANUP) window_to_3d_delta(ar, vec, 0, -25);
- else if(pandir == V3D_VIEW_PANDOWN) window_to_3d_delta(ar, vec, 0, 25);
+ if(pandir == V3D_VIEW_PANRIGHT) { mval_f[0]= -32.0f; ED_view3d_win_to_delta(ar, mval_f, vec); }
+ else if(pandir == V3D_VIEW_PANLEFT) { mval_f[0]= 32.0f; ED_view3d_win_to_delta(ar, mval_f, vec); }
+ else if(pandir == V3D_VIEW_PANUP) { mval_f[1]= -25.0f; ED_view3d_win_to_delta(ar, mval_f, vec); }
+ else if(pandir == V3D_VIEW_PANDOWN) { mval_f[1]= 25.0f; ED_view3d_win_to_delta(ar, mval_f, vec); }
add_v3_v3(rv3d->ofs, vec);
if(rv3d->viewlock & RV3D_BOXVIEW)
@@ -2795,7 +2798,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3];
- int mx, my, mval[2];
+ int mval[2];
// short ctrl= 0; // XXX
int flip;
fp= give_cursor(scene, v3d);
@@ -2803,9 +2806,6 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve
// if(obedit && ctrl) lr_click= 1;
copy_v3_v3(oldcurs, fp);
- mx= event->x - ar->winrct.xmin;
- my= event->y - ar->winrct.ymin;
-
project_int_noclip(ar, fp, mval);
flip= initgrabz(rv3d, fp[0], fp[1], fp[2]);
@@ -2822,23 +2822,22 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve
short depth_used = 0;
if (U.uiflag & USER_ORBIT_ZBUF) { /* maybe this should be accessed some other way */
- int mval_depth[2];
- mval_depth[0]= mx;
- mval_depth[1]= my;
view3d_operator_needs_opengl(C);
- if (view_autodist(scene, ar, v3d, mval_depth, fp))
+ if (ED_view3d_autodist(scene, ar, v3d, event->mval, fp))
depth_used= 1;
}
if(depth_used==0) {
- window_to_3d_delta(ar, dvec, mval[0]-mx, mval[1]-my);
+ float mval_f[2];
+ VECSUB2D(mval_f, mval, event->mval);
+ ED_view3d_win_to_delta(ar, mval_f, dvec);
sub_v3_v3(fp, dvec);
}
}
else {
- dx= ((float)(mx-(ar->winx/2)))*rv3d->zfac/(ar->winx/2);
- dy= ((float)(my-(ar->winy/2)))*rv3d->zfac/(ar->winy/2);
+ dx= ((float)(event->mval[0]-(ar->winx/2)))*rv3d->zfac/(ar->winx/2);
+ dy= ((float)(event->mval[1]-(ar->winy/2)))*rv3d->zfac/(ar->winy/2);
fz= rv3d->persmat[0][3]*fp[0]+ rv3d->persmat[1][3]*fp[1]+ rv3d->persmat[2][3]*fp[2]+ rv3d->persmat[3][3];
fz= fz/rv3d->zfac;
@@ -2981,7 +2980,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg
}
/* XXX todo Zooms in on a border drawn by the user */
-int view_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3] ) //, float *autodist )
+int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3] ) //, float *autodist )
{
bglMats mats; /* ZBuffer depth vars */
float depth_close= FLT_MAX;
@@ -3008,7 +3007,7 @@ int view_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], flo
return 1;
}
-int view_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //, float *autodist )
+int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //, float *autodist )
{
/* Get Z Depths, needed for perspective, nice for ortho */
switch(mode) {
@@ -3024,7 +3023,7 @@ int view_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //, flo
}
// no 4x4 sampling, run view_autodist_init first
-int view_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth) //, float *autodist )
+int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth) //, float *autodist )
{
bglMats mats; /* ZBuffer depth vars, could cache? */
float depth;
@@ -3052,7 +3051,7 @@ int view_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3]
return 1;
}
-int view_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth)
+int ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth)
{
*depth= view_autodist_depth_margin(ar, mval, margin);
@@ -3079,7 +3078,7 @@ static int depth_segment_cb(int x, int y, void *userData)
}
}
-int view_autodist_depth_segment(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth)
+int ED_view3d_autodist_depth_seg(struct 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};
int p1[2];
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index e37361fbc54..962bd5c7080 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -287,9 +287,7 @@ static int initFlyInfo (bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *even
fly->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
- fly->mval[0] = event->x - fly->ar->winrct.xmin;
- fly->mval[1] = event->y - fly->ar->winrct.ymin;
-
+ VECCOPY2D(fly->mval, event->mval)
fly->time_lastdraw= fly->time_lastwheel= PIL_check_seconds_timer();
@@ -418,8 +416,7 @@ static void flyEvent(FlyInfo *fly, wmEvent *event)
fly->redraw = 1;
}
else if (event->type == MOUSEMOVE) {
- fly->mval[0] = event->x - fly->ar->winrct.xmin;
- fly->mval[1] = event->y - fly->ar->winrct.ymin;
+ VECCOPY2D(fly->mval, event->mval);
} /* handle modal keymap first */
else if (event->type == EVT_MODAL_MAP) {
switch (event->val) {
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index a9f8a3f075a..f0c5b71dc1e 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -106,7 +106,9 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m
initgrabz(vc->rv3d, fp[0], fp[1], fp[2]);
if(mval_cpy[0]!=IS_CLIPPED) {
- window_to_3d_delta(vc->ar, dvec, mval_cpy[0]-mval[0], mval_cpy[1]-mval[1]);
+ float mval_f[2];
+ VECSUB2D(mval_f, mval_cpy, mval);
+ ED_view3d_win_to_delta(vc->ar, mval_f, dvec);
sub_v3_v3(fp, dvec);
return TRUE;
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index ac108caec80..cf04433e94a 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -52,6 +52,7 @@
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_scene.h"
+#include "BKE_screen.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
@@ -501,29 +502,20 @@ void view3d_calculate_clipping(BoundBox *bb, float planes[4][4], bglMats *mats,
}
/* create intersection coordinates in view Z direction at mouse coordinates */
-void viewline(ARegion *ar, View3D *v3d, float mval[2], float ray_start[3], float ray_end[3])
+void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3])
{
RegionView3D *rv3d= ar->regiondata;
- float vec[4];
- int a;
-
- if(!get_view3d_ortho(v3d, rv3d)) {
- vec[0]= 2.0f * mval[0] / ar->winx - 1;
- vec[1]= 2.0f * mval[1] / ar->winy - 1;
- vec[2]= -1.0f;
- vec[3]= 1.0f;
-
- mul_m4_v4(rv3d->persinv, vec);
- mul_v3_fl(vec, 1.0f / vec[3]);
-
+
+ if(rv3d->is_persp) {
+ float vec[3];
+ ED_view3d_win_to_vector(ar, mval, vec);
+
copy_v3_v3(ray_start, rv3d->viewinv[3]);
- sub_v3_v3(vec, ray_start);
- normalize_v3(vec);
-
VECADDFAC(ray_start, rv3d->viewinv[3], vec, v3d->near);
VECADDFAC(ray_end, rv3d->viewinv[3], vec, v3d->far);
}
else {
+ float vec[4];
vec[0] = 2.0f * mval[0] / ar->winx - 1;
vec[1] = 2.0f * mval[1] / ar->winy - 1;
vec[2] = 0.0f;
@@ -536,25 +528,27 @@ void viewline(ARegion *ar, View3D *v3d, float mval[2], float ray_start[3], float
}
/* clipping */
- if(rv3d->rflag & RV3D_CLIPPING)
- for(a=0; a<4; a++)
+ if(rv3d->rflag & RV3D_CLIPPING) {
+ int a;
+ for(a=0; a<4; a++) {
clip_line_plane(ray_start, ray_end, rv3d->clip[a]);
+ }
+ }
}
/* create intersection ray in view Z direction at mouse coordinates */
-void viewray(ARegion *ar, View3D *v3d, float mval[2], float ray_start[3], float ray_normal[3])
+void ED_view3d_win_to_ray(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3])
{
float ray_end[3];
- viewline(ar, v3d, mval, ray_start, ray_end);
+ ED_view3d_win_to_segment_clip(ar, v3d, mval, ray_start, ray_end);
sub_v3_v3v3(ray_normal, ray_end, ray_start);
normalize_v3(ray_normal);
}
-void viewvector(RegionView3D *rv3d, float coord[3], float vec[3])
+void ED_view3d_global_to_vector(RegionView3D *rv3d, const float coord[3], float vec[3])
{
- if (rv3d->persp != RV3D_ORTHO)
- {
+ if (rv3d->is_persp) {
float p1[4], p2[4];
copy_v3_v3(p1, coord);
@@ -598,32 +592,45 @@ int initgrabz(RegionView3D *rv3d, float x, float y, float z)
return flip;
}
-/* always call initgrabz */
-void window_to_3d(ARegion *ar, float out[3], const int mx, const int my)
+void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[2], float out[3])
{
RegionView3D *rv3d= ar->regiondata;
- float dx= ((float)(mx-(ar->winx/2)))*rv3d->zfac/(ar->winx/2);
- float dy= ((float)(my-(ar->winy/2)))*rv3d->zfac/(ar->winy/2);
-
- float fz= rv3d->persmat[0][3]*out[0]+ rv3d->persmat[1][3]*out[1]+ rv3d->persmat[2][3]*out[2]+ rv3d->persmat[3][3];
- fz= fz/rv3d->zfac;
-
- out[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy+ rv3d->persinv[2][0]*fz)-rv3d->ofs[0];
- out[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy+ rv3d->persinv[2][1]*fz)-rv3d->ofs[1];
- out[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy+ rv3d->persinv[2][2]*fz)-rv3d->ofs[2];
-
+ float line_sta[3];
+ float line_end[3];
+
+ if(rv3d->is_persp) {
+ float mousevec[3];
+ copy_v3_v3(line_sta, rv3d->viewinv[3]);
+ ED_view3d_win_to_vector(ar, mval, mousevec);
+ add_v3_v3v3(line_end, line_sta, mousevec);
+
+ if(isect_line_plane_v3(out, line_sta, line_end, depth_pt, rv3d->viewinv[2], TRUE) == 0) {
+ /* highly unlikely to ever happen, mouse vec paralelle with view plane */
+ zero_v3(out);
+ }
+ }
+ else {
+ const float dx= (2.0f * mval[0] / (float)ar->winx) - 1.0f;
+ const float dy= (2.0f * mval[1] / (float)ar->winy) - 1.0f;
+ line_sta[0]= (rv3d->persinv[0][0] * dx) + (rv3d->persinv[1][0] * dy) + rv3d->viewinv[3][0];
+ line_sta[1]= (rv3d->persinv[0][1] * dx) + (rv3d->persinv[1][1] * dy) + rv3d->viewinv[3][1];
+ line_sta[2]= (rv3d->persinv[0][2] * dx) + (rv3d->persinv[1][2] * dy) + rv3d->viewinv[3][2];
+
+ add_v3_v3v3(line_end, line_sta, rv3d->viewinv[2]);
+ closest_to_line_v3(out, depth_pt, line_sta, line_end);
+ }
}
/* always call initgrabz */
/* only to detect delta motion */
-void window_to_3d_delta(ARegion *ar, float out[3], const int mx, const int my)
+void ED_view3d_win_to_delta(ARegion *ar, const float mval[2], float out[3])
{
RegionView3D *rv3d= ar->regiondata;
float dx, dy;
- dx= 2.0f*mx*rv3d->zfac/ar->winx;
- dy= 2.0f*my*rv3d->zfac/ar->winy;
+ dx= 2.0f*mval[0]*rv3d->zfac/ar->winx;
+ dy= 2.0f*mval[1]*rv3d->zfac/ar->winy;
out[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy);
out[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy);
@@ -633,22 +640,20 @@ void window_to_3d_delta(ARegion *ar, float out[3], const int mx, const int my)
/* doesn't rely on initgrabz */
/* for perspective view, get the vector direction to
* the mouse cursor as a normalized vector */
-void window_to_3d_vector(ARegion *ar, float out[3], const int mx, const int my)
+void ED_view3d_win_to_vector(ARegion *ar, const float mval[2], float out[3])
{
RegionView3D *rv3d= ar->regiondata;
- float dx, dy;
- float viewvec[3];
-
- dx= (2.0f * mx / ar->winx) - 1.0f;
- dy= (2.0f * my / ar->winy) - 1.0f;
-
- /* normalize here so vecs are proportional to eachother */
- normalize_v3_v3(viewvec, rv3d->viewinv[2]);
-
- out[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy) - viewvec[0];
- out[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy) - viewvec[1];
- out[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy) - viewvec[2];
+ if(rv3d->is_persp) {
+ out[0]= 2.0f * (mval[0] / ar->winx) - 1.0f;
+ out[1]= 2.0f * (mval[1] / ar->winy) - 1.0f;
+ out[2]= -0.5f;
+ mul_project_m4_v3(rv3d->persinv, out);
+ sub_v3_v3(out, rv3d->viewinv[3]);
+ }
+ else {
+ copy_v3_v3(out, rv3d->viewinv[2]);
+ }
normalize_v3(out);
}
@@ -911,29 +916,6 @@ void project_float_noclip(ARegion *ar, const float vec[3], float adr[2])
}
}
-int get_view3d_ortho(View3D *v3d, RegionView3D *rv3d)
-{
- Camera *cam;
-
- if(rv3d->persp==RV3D_CAMOB) {
- if(v3d->camera && v3d->camera->type==OB_CAMERA) {
- cam= v3d->camera->data;
-
- if(cam && cam->type==CAM_ORTHO)
- return 1;
- else
- return 0;
- }
- else
- return 0;
- }
-
- if(rv3d->persp==RV3D_ORTHO)
- return 1;
-
- return 0;
-}
-
/* copies logic of get_view3d_viewplane(), keep in sync */
int get_view3d_cliprange(View3D *v3d, RegionView3D *rv3d, float *clipsta, float *clipend)
{
@@ -1021,10 +1003,11 @@ int get_view3d_viewplane(View3D *v3d, RegionView3D *rv3d, int winxi, int winyi,
else {
/* fac for zoom, also used for camdx */
if(rv3d->persp==RV3D_CAMOB) {
- fac= (1.41421f + ( (float)rv3d->camzoom )/50.0f);
- fac*= fac;
+ fac= BKE_screen_view3d_zoom_to_fac((float)rv3d->camzoom) * 4.0f;
+ }
+ else {
+ fac= 2.0;
}
- else fac= 2.0;
/* viewplane size depends... */
if(cam && cam->type==CAM_ORTHO) {
@@ -1103,6 +1086,8 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for pick
int orth;
orth= get_view3d_viewplane(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend, NULL);
+ rv3d->is_persp= !orth;
+
// printf("%d %d %f %f %f %f %f %f\n", winx, winy, viewplane.xmin, viewplane.ymin, viewplane.xmax, viewplane.ymax, clipsta, clipend);
x1= viewplane.xmin;
y1= viewplane.ymin;
@@ -1909,11 +1894,6 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f
}
}
-int view3d_is_ortho(View3D *v3d, RegionView3D *rv3d)
-{
- return (rv3d->persp == RV3D_ORTHO || (v3d->camera && ((Camera *)v3d->camera->data)->type == CAM_ORTHO));
-}
-
float view3d_pixel_size(struct RegionView3D *rv3d, const float co[3])
{
return (rv3d->persmat[3][3] + (
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index f1eff710c7d..1afa5ead044 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -127,9 +127,11 @@ void setTransformViewMatrices(TransInfo *t)
void convertViewVec(TransInfo *t, float *vec, int dx, int dy)
{
if (t->spacetype==SPACE_VIEW3D) {
- if (t->ar->regiontype == RGN_TYPE_WINDOW)
- {
- window_to_3d_delta(t->ar, vec, dx, dy);
+ if (t->ar->regiontype == RGN_TYPE_WINDOW) {
+ float mval_f[2];
+ mval_f[0]= dx;
+ mval_f[1]= dy;
+ ED_view3d_win_to_delta(t->ar, mval_f, vec);
}
}
else if(t->spacetype==SPACE_IMAGE) {
@@ -571,8 +573,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
if (t->modifiers & MOD_CONSTRAINT_SELECT)
t->con.mode |= CON_SELECT;
- t->mval[0] = event->x - t->ar->winrct.xmin;
- t->mval[1] = event->y - t->ar->winrct.ymin;
+ VECCOPY2D(t->mval, event->mval);
// t->redraw |= TREDRAW_SOFT; /* Use this for soft redraw. Might cause flicker in object mode */
t->redraw |= TREDRAW_HARD;
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 1b0db37cd76..708a59d6536 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -660,7 +660,7 @@ typedef enum {
void initMouseInput(TransInfo *t, MouseInput *mi, int center[2], int mval[2]);
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode);
int handleMouseInput(struct TransInfo *t, struct MouseInput *mi, struct wmEvent *event);
-void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, int mval[2], float output[3]);
+void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, const int mval[2], float output[3]);
void setCustomPoints(TransInfo *t, MouseInput *mi, int start[2], int end[2]);
void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3]));
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 8804b2d2cae..4a601f37e17 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -5456,7 +5456,7 @@ void createTransData(bContext *C, TransInfo *t)
sort_trans_data_dist(t);
}
- if (t->ar->regiontype == RGN_TYPE_WINDOW)
+ if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW))
{
View3D *v3d = t->view;
RegionView3D *rv3d = CTX_wm_region_view3d(C);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 44320c9e8af..60f5ee02b13 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -922,9 +922,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
if (event)
{
- t->imval[0] = event->x - t->ar->winrct.xmin;
- t->imval[1] = event->y - t->ar->winrct.ymin;
-
+ VECCOPY2D(t->imval, event->mval);
t->event_type = event->type;
}
else
@@ -1041,9 +1039,14 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
}
else
{
- // XXX for now, get View2D from the active region
- t->view = &ar->v2d;
- // XXX for now, the center point is the midpoint of the data
+ if(ar) {
+ // XXX for now, get View2D from the active region
+ t->view = &ar->v2d;
+ // XXX for now, the center point is the midpoint of the data
+ }
+ else {
+ t->view= NULL;
+ }
t->around = V3D_CENTER;
}
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 7a16e25302c..b3608305a7a 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -372,7 +372,7 @@ void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3])
mi->post = post;
}
-void applyMouseInput(TransInfo *t, MouseInput *mi, int mval[2], float output[3])
+void applyMouseInput(TransInfo *t, MouseInput *mi, const int mval[2], float output[3])
{
if (mi->apply != NULL)
{
@@ -398,8 +398,7 @@ int handleMouseInput(TransInfo *t, MouseInput *mi, wmEvent *event)
t->modifiers |= MOD_PRECISION;
/* shift is modifier for higher precision transform
* store the mouse position where the normal movement ended */
- mi->precision_mval[0] = event->x - t->ar->winrct.xmin;
- mi->precision_mval[1] = event->y - t->ar->winrct.ymin;
+ VECCOPY2D(mi->precision_mval, event->mval);
mi->precision = 1;
}
else
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 52386c7af10..71c2d062ee2 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -560,7 +560,7 @@ static void test_manipulator_axis(const bContext *C)
float angle;
float vec[3];
- viewvector(rv3d, rv3d->twmat[3], vec);
+ ED_view3d_global_to_vector(rv3d, rv3d->twmat[3], vec);
angle = fabs(angle_v3v3(rv3d->twmat[0], vec));
if (angle > (float)M_PI / 2.0f) {
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 4edaabb9508..7bdf6c909d9 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -514,7 +514,7 @@ void TRANSFORM_OT_translate(struct wmOperatorType *ot)
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
- ot->poll = ED_operator_areaactive;
+ ot->poll = ED_operator_screenactive;
RNA_def_float_vector_xyz(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
@@ -534,7 +534,7 @@ void TRANSFORM_OT_resize(struct wmOperatorType *ot)
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
- ot->poll = ED_operator_areaactive;
+ ot->poll = ED_operator_screenactive;
RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
@@ -555,7 +555,7 @@ void TRANSFORM_OT_trackball(struct wmOperatorType *ot)
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
- ot->poll = ED_operator_areaactive;
+ ot->poll = ED_operator_screenactive;
RNA_def_float_vector(ot->srna, "value", 2, VecOne, -FLT_MAX, FLT_MAX, "angle", "", -FLT_MAX, FLT_MAX);
@@ -575,7 +575,7 @@ void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
- ot->poll = ED_operator_areaactive;
+ ot->poll = ED_operator_screenactive;
RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI*2, M_PI*2);
@@ -618,7 +618,7 @@ void TRANSFORM_OT_warp(struct wmOperatorType *ot)
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
- ot->poll = ED_operator_areaactive;
+ ot->poll = ED_operator_screenactive;
RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", 0, 1);
@@ -639,7 +639,7 @@ void TRANSFORM_OT_shear(struct wmOperatorType *ot)
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
- ot->poll = ED_operator_areaactive;
+ ot->poll = ED_operator_screenactive;
RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
@@ -660,7 +660,7 @@ void TRANSFORM_OT_push_pull(struct wmOperatorType *ot)
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
- ot->poll = ED_operator_areaactive;
+ ot->poll = ED_operator_screenactive;
RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Distance", "", -FLT_MAX, FLT_MAX);
@@ -701,7 +701,7 @@ void TRANSFORM_OT_tosphere(struct wmOperatorType *ot)
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
- ot->poll = ED_operator_areaactive;
+ ot->poll = ED_operator_screenactive;
RNA_def_float_factor(ot->srna, "value", 0, 0, 1, "Factor", "", 0, 1);
@@ -721,7 +721,7 @@ void TRANSFORM_OT_mirror(struct wmOperatorType *ot)
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
- ot->poll = ED_operator_areaactive;
+ ot->poll = ED_operator_screenactive;
Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL);
}
@@ -801,7 +801,7 @@ void TRANSFORM_OT_transform(struct wmOperatorType *ot)
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
- ot->poll = ED_operator_areaactive;
+ ot->poll = ED_operator_screenactive;
prop= RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 6ab4cb126d3..23d11e1562f 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -1599,7 +1599,7 @@ static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, f
int retval = 0;
float ray_start[3], ray_normal[3];
- viewray(ar, v3d, mval, ray_start, ray_normal);
+ ED_view3d_win_to_ray(ar, v3d, mval, ray_start, ray_normal);
if (mode == SNAP_ALL && obedit)
{
@@ -1830,7 +1830,7 @@ static int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, L
int retval = 0;
float ray_start[3], ray_normal[3];
- viewray(ar, v3d, mval, ray_start, ray_normal);
+ ED_view3d_win_to_ray(ar, v3d, mval, ray_start, ray_normal);
for ( base = scene->base.first; base != NULL; base = base->next ) {
if ( BASE_SELECTABLE(v3d, base) ) {
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c
index 60f551afa6e..9ac44f482a1 100644
--- a/source/blender/editors/util/undo.c
+++ b/source/blender/editors/util/undo.c
@@ -260,7 +260,7 @@ int ED_undo_valid(const bContext *C, const char *undoname)
static int ed_undo_exec(bContext *C, wmOperator *UNUSED(op))
{
/* "last operator" should disappear, later we can tie ths with undo stack nicer */
- WM_operator_stack_clear(C);
+ WM_operator_stack_clear(CTX_wm_manager(C));
return ed_undo_step(C, 1, NULL);
}
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index eb621fd6bf1..326b7b89af7 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -1942,12 +1942,8 @@ static int select_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
ARegion *ar= CTX_wm_region(C);
float co[2];
- int x, y;
- x= event->x - ar->winrct.xmin;
- y= event->y - ar->winrct.ymin;
-
- UI_view2d_region_to_view(&ar->v2d, x, y, &co[0], &co[1]);
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
RNA_float_set_array(op->ptr, "location", co);
return select_exec(C, op);
@@ -1991,12 +1987,8 @@ static int select_loop_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
ARegion *ar= CTX_wm_region(C);
float co[2];
- int x, y;
-
- x= event->x - ar->winrct.xmin;
- y= event->y - ar->winrct.ymin;
- UI_view2d_region_to_view(&ar->v2d, x, y, &co[0], &co[1]);
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
RNA_float_set_array(op->ptr, "location", co);
return select_loop_exec(C, op);
@@ -2051,12 +2043,8 @@ static int select_linked_internal(bContext *C, wmOperator *op, wmEvent *event, i
if(event) {
/* invoke */
ARegion *ar= CTX_wm_region(C);
- int x, y;
- x= event->x - ar->winrct.xmin;
- y= event->y - ar->winrct.ymin;
-
- UI_view2d_region_to_view(&ar->v2d, x, y, &co[0], &co[1]);
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
RNA_float_set_array(op->ptr, "location", co);
}
else {
@@ -3163,12 +3151,9 @@ static int set_2d_cursor_exec(bContext *C, wmOperator *op)
static int set_2d_cursor_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
ARegion *ar= CTX_wm_region(C);
- int x, y;
float location[2];
- x= event->x - ar->winrct.xmin;
- y= event->y - ar->winrct.ymin;
- UI_view2d_region_to_view(&ar->v2d, x, y, &location[0], &location[1]);
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
RNA_float_set_array(op->ptr, "location", location);
return set_2d_cursor_exec(C, op);
@@ -3219,14 +3204,12 @@ static int set_tile_invoke(bContext *C, wmOperator *op, wmEvent *event)
Image *ima= CTX_data_edit_image(C);
ARegion *ar= CTX_wm_region(C);
float fx, fy;
- int x, y, tile[2];
+ int tile[2];
if(!ima || !(ima->tpageflag & IMA_TILES))
return OPERATOR_CANCELLED;
- x= event->x - ar->winrct.xmin;
- y= event->y - ar->winrct.ymin;
- UI_view2d_region_to_view(&ar->v2d, x, y, &fx, &fy);
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy);
if(fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
fx= fx*ima->xrep;
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 6b6dcdb88af..f0c06ec0ae7 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -391,7 +391,7 @@ struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags)
if (png_get_valid (png_ptr, info_ptr, PNG_INFO_pHYs)) {
int unit_type;
- unsigned int xres, yres;
+ png_uint_32 xres, yres;
if(png_get_pHYs(png_ptr, info_ptr, &xres, &yres, &unit_type))
if(unit_type == PNG_RESOLUTION_METER) {
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 60fa48d9717..7379493003d 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -96,10 +96,13 @@ typedef struct RegionView3D {
float zfac; /* initgrabz() result */
float camdx, camdy; /* camera view offsets, 1.0 = viewplane moves entire width/height */
float pixsize; /* runtime only */
- float ofs[3]; /* view center & orbit pivot, negative of worldspace location */
- short camzoom;
+ float ofs[3]; /* view center & orbit pivot, negative of worldspace location,
+ * also matches -viewinv[3][0:3] in ortho mode.*/
+ short camzoom; /* viewport zoom on the camera frame, see BKE_screen_view3d_zoom_to_fac */
short twdrawflag;
- int pad;
+ char is_persp; /* check if persp/ortho view, since 'persp' cant be used for this since
+ * it can have cameras assigned as well. (only set in setwinmatrixview3d) */
+ char pad[3];
short rflag, viewlock;
short persp;
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 4672a77bd06..a9f7d9f246f 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -31,7 +31,6 @@
#include <stdarg.h>
-#include "DNA_listBase.h"
#include "RNA_types.h"
#ifdef __cplusplus
@@ -40,6 +39,7 @@ extern "C" {
struct bContext;
struct ID;
+struct ListBase;
struct Main;
struct ReportList;
struct Scene;
@@ -611,6 +611,7 @@ int RNA_struct_is_a(StructRNA *type, StructRNA *srna);
StructRegisterFunc RNA_struct_register(StructRNA *type);
StructUnregisterFunc RNA_struct_unregister(StructRNA *type);
+void **RNA_struct_instance(PointerRNA *ptr);
void *RNA_struct_py_type_get(StructRNA *srna);
void RNA_struct_py_type_set(StructRNA *srna, void *py_type);
@@ -903,7 +904,7 @@ int RNA_property_is_idprop(PropertyRNA *prop);
/* python compatible string representation of this property, (must be freed!) */
char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop);
-char *RNA_pointer_as_string(PointerRNA *ptr);
+char *RNA_pointer_as_string(struct bContext *C, PointerRNA *ptr);
/* Function */
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index f131f7c9ebe..f52a69182b5 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -60,7 +60,7 @@ void RNA_def_struct_flag(StructRNA *srna, int flag);
void RNA_def_struct_clear_flag(StructRNA *srna, int flag);
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine);
void RNA_def_struct_idprops_func(StructRNA *srna, const char *refine);
-void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg);
+void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance);
void RNA_def_struct_path_func(StructRNA *srna, const char *path);
void RNA_def_struct_identifier(StructRNA *srna, const char *identifier);
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description);
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 3a15146770f..ec6f05c0e6a 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -43,6 +43,7 @@ struct StructRNA;
struct BlenderRNA;
struct IDProperty;
struct bContext;
+struct Main;
struct ReportList;
/** Pointer
@@ -329,9 +330,10 @@ typedef enum StructFlag {
typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function);
typedef int (*StructCallbackFunc)(struct bContext *C, struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list);
typedef void (*StructFreeFunc)(void *data);
-typedef struct StructRNA *(*StructRegisterFunc)(struct bContext *C, struct ReportList *reports, void *data,
+typedef struct StructRNA *(*StructRegisterFunc)(struct Main *bmain, struct ReportList *reports, void *data,
const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free);
-typedef void (*StructUnregisterFunc)(const struct bContext *C, struct StructRNA *type);
+typedef void (*StructUnregisterFunc)(struct Main *bmain, struct StructRNA *type);
+typedef void **(*StructInstanceFunc)(PointerRNA *ptr);
typedef struct StructRNA StructRNA;
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 97d0f535a5b..fe6fc91eff4 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -193,7 +193,17 @@ static int replace_if_different(char *tmpfile, const char *dep_files[])
#undef REN_IF_DIFF
}
+/* Helper to solve keyword problems with C/C++ */
+static const char *rna_safe_id(const char *id)
+{
+ if(strcmp(id, "default") == 0)
+ return "default_value";
+ else if(strcmp(id, "operator") == 0)
+ return "operator_value";
+
+ return id;
+}
/* Sorting */
@@ -501,7 +511,7 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
}
- func= rna_alloc_function_name(srna->identifier, prop->identifier, "get");
+ func= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
switch(prop->type) {
case PROP_STRING: {
@@ -569,7 +579,7 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
rna_print_data_get(f, dp);
if(prop->flag & PROP_DYNAMIC) {
- char *lenfunc= rna_alloc_function_name(srna->identifier, prop->identifier, "get_length");
+ char *lenfunc= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get_length");
fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc);
fprintf(f, " for(i=0; i<len; i++) {\n");
@@ -684,7 +694,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
}
}
- func= rna_alloc_function_name(srna->identifier, prop->identifier, "set");
+ func= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "set");
switch(prop->type) {
case PROP_STRING: {
@@ -754,7 +764,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
rna_print_data_get(f, dp);
if(prop->flag & PROP_DYNAMIC) {
- char *lenfunc= rna_alloc_function_name(srna->identifier, prop->identifier, "set_length");
+ char *lenfunc= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "set_length");
fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc);
fprintf(f, " for(i=0; i<len; i++) {\n");
@@ -851,7 +861,7 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA
}
}
- func= rna_alloc_function_name(srna->identifier, prop->identifier, "length");
+ func= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "length");
fprintf(f, "int %s(PointerRNA *ptr)\n", func);
fprintf(f, "{\n");
@@ -873,7 +883,7 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA
}
}
- func= rna_alloc_function_name(srna->identifier, prop->identifier, "length");
+ func= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "length");
fprintf(f, "int %s(PointerRNA *ptr)\n", func);
fprintf(f, "{\n");
@@ -908,7 +918,7 @@ static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *
}
}
- func= rna_alloc_function_name(srna->identifier, prop->identifier, "begin");
+ func= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "begin");
fprintf(f, "void %s(CollectionPropertyIterator *iter, PointerRNA *ptr)\n", func);
fprintf(f, "{\n");
@@ -940,7 +950,7 @@ static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *
fprintf(f, "\n rna_iterator_listbase_begin(iter, data->%s, NULL);\n", dp->dnaname);
}
- getfunc= rna_alloc_function_name(srna->identifier, prop->identifier, "get");
+ getfunc= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
fprintf(f, "\n if(iter->valid)\n");
fprintf(f, " iter->ptr= %s(iter);\n", getfunc);
@@ -970,7 +980,7 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
else return NULL;
}
- func= rna_alloc_function_name(srna->identifier, prop->identifier, "lookup_int");
+ func= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "lookup_int");
fprintf(f, "int %s(PointerRNA *ptr, int index, PointerRNA *r_ptr)\n", func);
fprintf(f, "{\n");
@@ -984,7 +994,7 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
fprintf(f, " int found= 0;\n");
fprintf(f, " CollectionPropertyIterator iter;\n\n");
- fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, prop->identifier);
+ fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, rna_safe_id(prop->identifier));
fprintf(f, " if(iter.valid){\n");
if(strcmp(nextfunc, "rna_iterator_array_next") == 0) {
@@ -1022,9 +1032,9 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
fprintf(f, " }\n");
}
- fprintf(f, " if(found) *r_ptr = %s_%s_get(&iter);\n", srna->identifier, prop->identifier);
+ fprintf(f, " if(found) *r_ptr = %s_%s_get(&iter);\n", srna->identifier, rna_safe_id(prop->identifier));
fprintf(f, " }\n\n");
- fprintf(f, " %s_%s_end(&iter);\n\n", srna->identifier, prop->identifier);
+ fprintf(f, " %s_%s_end(&iter);\n\n", srna->identifier, rna_safe_id(prop->identifier));
fprintf(f, " return found;\n");
@@ -1061,13 +1071,13 @@ static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *p
if(!manualfunc)
return NULL;
- func= rna_alloc_function_name(srna->identifier, prop->identifier, "next");
+ func= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "next");
fprintf(f, "void %s(CollectionPropertyIterator *iter)\n", func);
fprintf(f, "{\n");
fprintf(f, " %s(iter);\n", manualfunc);
- getfunc= rna_alloc_function_name(srna->identifier, prop->identifier, "get");
+ getfunc= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
fprintf(f, "\n if(iter->valid)\n");
fprintf(f, " iter->ptr= %s(iter);\n", getfunc);
@@ -1084,7 +1094,7 @@ static char *rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *pr
if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL)
return NULL;
- func= rna_alloc_function_name(srna->identifier, prop->identifier, "end");
+ func= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "end");
fprintf(f, "void %s(CollectionPropertyIterator *iter)\n", func);
fprintf(f, "{\n");
@@ -1272,7 +1282,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
if(prop->flag & (PROP_IDPROPERTY|PROP_BUILTIN))
return;
- func= rna_alloc_function_name(srna->identifier, prop->identifier, "");
+ func= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "");
switch(prop->type) {
case PROP_BOOLEAN:
@@ -1281,10 +1291,14 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
fprintf(f, "int %sget(PointerRNA *ptr);\n", func);
//fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func);
}
- else {
+ else if(prop->arraydimension && prop->totarraylength) {
fprintf(f, "void %sget(PointerRNA *ptr, int values[%d]);\n", func, prop->totarraylength);
//fprintf(f, "void %sset(PointerRNA *ptr, const int values[%d]);\n", func, prop->arraylength);
}
+ else {
+ fprintf(f, "void %sget(PointerRNA *ptr, int values[]);\n", func);
+ //fprintf(f, "void %sset(PointerRNA *ptr, const int values[]);\n", func);
+ }
break;
}
case PROP_FLOAT: {
@@ -1292,10 +1306,14 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
fprintf(f, "float %sget(PointerRNA *ptr);\n", func);
//fprintf(f, "void %sset(PointerRNA *ptr, float value);\n", func);
}
- else {
+ else if(prop->arraydimension && prop->totarraylength) {
fprintf(f, "void %sget(PointerRNA *ptr, float values[%d]);\n", func, prop->totarraylength);
//fprintf(f, "void %sset(PointerRNA *ptr, const float values[%d]);\n", func, prop->arraylength);
}
+ else {
+ fprintf(f, "void %sget(PointerRNA *ptr, float values[]);\n", func);
+ //fprintf(f, "void %sset(PointerRNA *ptr, const float values[]);\n", func);
+ }
break;
}
case PROP_ENUM: {
@@ -1368,23 +1386,23 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
switch(prop->type) {
case PROP_BOOLEAN: {
if(!prop->arraydimension)
- fprintf(f, "\tbool %s(void);", prop->identifier);
+ fprintf(f, "\tinline bool %s(void);", rna_safe_id(prop->identifier));
else
- fprintf(f, "\tArray<int, %d> %s(void);", prop->totarraylength, prop->identifier);
+ fprintf(f, "\tinline Array<int, %d> %s(void);", prop->totarraylength, rna_safe_id(prop->identifier));
break;
}
case PROP_INT: {
if(!prop->arraydimension)
- fprintf(f, "\tint %s(void);", prop->identifier);
+ fprintf(f, "\tinline int %s(void);", rna_safe_id(prop->identifier));
else
- fprintf(f, "\tArray<int, %d> %s(void);", prop->totarraylength, prop->identifier);
+ fprintf(f, "\tinline Array<int, %d> %s(void);", prop->totarraylength, rna_safe_id(prop->identifier));
break;
}
case PROP_FLOAT: {
if(!prop->arraydimension)
- fprintf(f, "\tfloat %s(void);", prop->identifier);
+ fprintf(f, "\tinline float %s(void);", rna_safe_id(prop->identifier));
else
- fprintf(f, "\tArray<float, %d> %s(void);", prop->totarraylength, prop->identifier);
+ fprintf(f, "\tinline Array<float, %d> %s(void);", prop->totarraylength, rna_safe_id(prop->identifier));
break;
}
case PROP_ENUM: {
@@ -1392,38 +1410,38 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
int i;
if(eprop->item) {
- fprintf(f, "\tenum %s_enum {\n", prop->identifier);
+ fprintf(f, "\tenum %s_enum {\n", rna_safe_id(prop->identifier));
for(i=0; i<eprop->totitem; i++)
if(eprop->item[i].identifier[0])
- fprintf(f, "\t\t%s_%s = %d,\n", prop->identifier, eprop->item[i].identifier, eprop->item[i].value);
+ fprintf(f, "\t\t%s_%s = %d,\n", rna_safe_id(prop->identifier), eprop->item[i].identifier, eprop->item[i].value);
fprintf(f, "\t};\n");
}
- fprintf(f, "\t%s_enum %s(void);", prop->identifier, prop->identifier);
+ fprintf(f, "\tinline %s_enum %s(void);", rna_safe_id(prop->identifier), rna_safe_id(prop->identifier));
break;
}
case PROP_STRING: {
- fprintf(f, "\tstd::string %s(void);", prop->identifier);
+ fprintf(f, "\tinline std::string %s(void);", rna_safe_id(prop->identifier));
break;
}
case PROP_POINTER: {
PointerPropertyRNA *pprop= (PointerPropertyRNA*)dp->prop;
if(pprop->type)
- fprintf(f, "\t%s %s(void);", (char*)pprop->type, prop->identifier);
+ fprintf(f, "\tinline %s %s(void);", (char*)pprop->type, rna_safe_id(prop->identifier));
else
- fprintf(f, "\t%s %s(void);", "UnknownType", prop->identifier);
+ fprintf(f, "\tinline %s %s(void);", "UnknownType", rna_safe_id(prop->identifier));
break;
}
case PROP_COLLECTION: {
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)dp->prop;
if(cprop->item_type)
- fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (char*)cprop->item_type, srna->identifier, prop->identifier);
+ fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (char*)cprop->item_type, srna->identifier, rna_safe_id(prop->identifier));
else
- fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, prop->identifier);
+ fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, rna_safe_id(prop->identifier));
break;
}
}
@@ -1443,41 +1461,41 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe
switch(prop->type) {
case PROP_BOOLEAN: {
if(!prop->arraydimension)
- fprintf(f, "\tBOOLEAN_PROPERTY(%s, %s)", srna->identifier, prop->identifier);
+ fprintf(f, "\tBOOLEAN_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
else
- fprintf(f, "\tBOOLEAN_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->totarraylength, prop->identifier);
+ fprintf(f, "\tBOOLEAN_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->totarraylength, rna_safe_id(prop->identifier));
break;
}
case PROP_INT: {
if(!prop->arraydimension)
- fprintf(f, "\tINT_PROPERTY(%s, %s)", srna->identifier, prop->identifier);
+ fprintf(f, "\tINT_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
else
- fprintf(f, "\tINT_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->totarraylength, prop->identifier);
+ fprintf(f, "\tINT_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->totarraylength, rna_safe_id(prop->identifier));
break;
}
case PROP_FLOAT: {
if(!prop->arraydimension)
- fprintf(f, "\tFLOAT_PROPERTY(%s, %s)", srna->identifier, prop->identifier);
+ fprintf(f, "\tFLOAT_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
else
- fprintf(f, "\tFLOAT_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->totarraylength, prop->identifier);
+ fprintf(f, "\tFLOAT_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->totarraylength, rna_safe_id(prop->identifier));
break;
}
case PROP_ENUM: {
- fprintf(f, "\tENUM_PROPERTY(%s_enum, %s, %s)", prop->identifier, srna->identifier, prop->identifier);
+ fprintf(f, "\tENUM_PROPERTY(%s_enum, %s, %s)", rna_safe_id(prop->identifier), srna->identifier, rna_safe_id(prop->identifier));
break;
}
case PROP_STRING: {
- fprintf(f, "\tSTRING_PROPERTY(%s, %s)", srna->identifier, prop->identifier);
+ fprintf(f, "\tSTRING_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
break;
}
case PROP_POINTER: {
PointerPropertyRNA *pprop= (PointerPropertyRNA*)dp->prop;
if(pprop->type)
- fprintf(f, "\tPOINTER_PROPERTY(%s, %s, %s)", (char*)pprop->type, srna->identifier, prop->identifier);
+ fprintf(f, "\tPOINTER_PROPERTY(%s, %s, %s)", (char*)pprop->type, srna->identifier, rna_safe_id(prop->identifier));
else
- fprintf(f, "\tPOINTER_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, prop->identifier);
+ fprintf(f, "\tPOINTER_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, rna_safe_id(prop->identifier));
break;
}
case PROP_COLLECTION: {
@@ -2337,6 +2355,7 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
fprintf(f, "\t%s,\n", rna_function_string(srna->path));
fprintf(f, "\t%s,\n", rna_function_string(srna->reg));
fprintf(f, "\t%s,\n", rna_function_string(srna->unreg));
+ fprintf(f, "\t%s,\n", rna_function_string(srna->instance));
fprintf(f, "\t%s,\n", rna_function_string(srna->idproperties));
if(srna->reg && !srna->refine) {
@@ -2546,40 +2565,40 @@ static const char *cpp_classes = ""
"\n"
"#include <string>\n"
"\n"
-"namespace RNA {\n"
+"namespace BL {\n"
"\n"
"#define BOOLEAN_PROPERTY(sname, identifier) \\\n"
-" bool sname::identifier(void) { return (bool)sname##_##identifier##_get(&ptr); }\n"
+" inline bool sname::identifier(void) { return sname##_##identifier##_get(&ptr)? true: false; }\n"
"\n"
"#define BOOLEAN_ARRAY_PROPERTY(sname, size, identifier) \\\n"
-" Array<int,size> sname::identifier(void) \\\n"
+" inline Array<int,size> sname::identifier(void) \\\n"
" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n"
"\n"
"#define INT_PROPERTY(sname, identifier) \\\n"
-" int sname::identifier(void) { return sname##_##identifier##_get(&ptr); }\n"
+" inline int sname::identifier(void) { return sname##_##identifier##_get(&ptr); }\n"
"\n"
"#define INT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
-" Array<int,size> sname::identifier(void) \\\n"
+" inline Array<int,size> sname::identifier(void) \\\n"
" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n"
"\n"
"#define FLOAT_PROPERTY(sname, identifier) \\\n"
-" float sname::identifier(void) { return sname##_##identifier##_get(&ptr); }\n"
+" inline float sname::identifier(void) { return sname##_##identifier##_get(&ptr); }\n"
"\n"
"#define FLOAT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
-" Array<float,size> sname::identifier(void) \\\n"
+" inline Array<float,size> sname::identifier(void) \\\n"
" { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n"
"\n"
"#define ENUM_PROPERTY(type, sname, identifier) \\\n"
-" sname::type sname::identifier(void) { return (type)sname##_##identifier##_get(&ptr); }\n"
+" inline sname::type sname::identifier(void) { return (type)sname##_##identifier##_get(&ptr); }\n"
"\n"
"#define STRING_PROPERTY(sname, identifier) \\\n"
-" std::string sname::identifier(void) { \\\n"
+" inline std::string sname::identifier(void) { \\\n"
" int len= sname##_##identifier##_length(&ptr); \\\n"
" std::string str; str.resize(len); \\\n"
" sname##_##identifier##_get(&ptr, &str[0]); return str; } \\\n"
"\n"
"#define POINTER_PROPERTY(type, sname, identifier) \\\n"
-" type sname::identifier(void) { return type(sname##_##identifier##_get(&ptr)); }\n"
+" inline type sname::identifier(void) { return type(sname##_##identifier##_get(&ptr)); }\n"
"\n"
"#define COLLECTION_PROPERTY(type, sname, identifier) \\\n"
" typedef CollectionIterator<type, sname##_##identifier##_begin, \\\n"
@@ -2591,7 +2610,7 @@ static const char *cpp_classes = ""
"public:\n"
" Pointer(const PointerRNA& p) : ptr(p) { }\n"
" operator const PointerRNA&() { return ptr; }\n"
-" bool is_a(StructRNA *type) { return RNA_struct_is_a(&ptr, type); }\n"
+" bool is_a(StructRNA *type) { return RNA_struct_is_a(ptr.type, type)? true: false; }\n"
" operator void*() { return ptr.data; }\n"
" operator bool() { return ptr.data != NULL; }\n"
"\n"
@@ -2615,12 +2634,13 @@ static const char *cpp_classes = ""
"public:\n"
" CollectionIterator() : t(iter.ptr), init(false) { iter.valid= false; }\n"
" ~CollectionIterator(void) { if(init) Tend(&iter); };\n"
-" const CollectionIterator<T, Tbegin, Tnext, Tend>& operator=(const CollectionIterator<T, Tbegin, Tnext, Tend>& copy)\n"
-" { if(init) Tend(&iter); iter= copy.iter; if(iter.internal) iter.internal= MEM_dupallocN(iter.internal); t= copy.t; init= copy.init; return *this; }\n"
"\n"
" operator bool(void)\n"
" { return iter.valid != 0; }\n"
" const CollectionIterator<T, Tbegin, Tnext, Tend>& operator++() { Tnext(&iter); t = T(iter.ptr); return *this; }\n"
+" const CollectionIterator<T, Tbegin, Tnext, Tend>& operator=(const CollectionIterator<T, Tbegin, Tnext, Tend>& copy)\n"
+" { if(init) Tend(&iter); iter= copy.iter; if(iter.internal) iter.internal= MEM_dupallocN(iter.internal); t= copy.t; init= copy.init; return *this; }\n"
+"\n"
" T& operator*(void) { return t; }\n"
" T* operator->(void) { return &t; }\n"
" bool operator==(const CollectionIterator<T, Tbegin, Tnext, Tend>& other) { return iter.valid == other.iter.valid; }\n"
@@ -2661,7 +2681,7 @@ static void rna_generate_header_cpp(BlenderRNA *brna, FILE *f)
fprintf(f, "/* Automatically generated classes for the Data API.\n"
" Do not edit manually, changes will be overwritten. */\n\n");
-
+
fprintf(f, "#include \"RNA_blender.h\"\n");
fprintf(f, "#include \"RNA_types.h\"\n");
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index bde7c99c7df..46ad059ca02 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -210,12 +210,12 @@ IDProperty *rna_PropertyGroup_idprops(PointerRNA *ptr, int create)
return ptr->data;
}
-void rna_PropertyGroup_unregister(const bContext *C, StructRNA *type)
+void rna_PropertyGroup_unregister(Main *bmain, StructRNA *type)
{
RNA_struct_free(&BLENDER_RNA, type);
}
-StructRNA *rna_PropertyGroup_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+StructRNA *rna_PropertyGroup_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
PointerRNA dummyptr;
@@ -384,7 +384,7 @@ static void rna_def_ID_properties(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "IDPropertyGroup");
RNA_def_struct_ui_text(srna, "ID Property Group", "Group of ID properties");
RNA_def_struct_idprops_func(srna, "rna_PropertyGroup_idprops");
- RNA_def_struct_register_funcs(srna, "rna_PropertyGroup_register", "rna_PropertyGroup_unregister");
+ RNA_def_struct_register_funcs(srna, "rna_PropertyGroup_register", "rna_PropertyGroup_unregister", NULL);
RNA_def_struct_refine_func(srna, "rna_PropertyGroup_refine");
/* important so python types can have their name used in list views
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 03622ec756f..ff54ac6254f 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -681,6 +681,18 @@ StructUnregisterFunc RNA_struct_unregister(StructRNA *type)
return NULL;
}
+void **RNA_struct_instance(PointerRNA *ptr)
+{
+ StructRNA *type= ptr->type;
+
+ do {
+ if(type->instance)
+ return type->instance(ptr);
+ } while((type=type->base));
+
+ return NULL;
+}
+
void *RNA_struct_py_type_get(StructRNA *srna)
{
return srna->py_type;
@@ -1107,21 +1119,26 @@ int RNA_property_enum_value(bContext *C, PointerRNA *ptr, PropertyRNA *prop, con
{
EnumPropertyItem *item, *item_array;
int free, found;
-
+
RNA_property_enum_items(C, ptr, prop, &item_array, NULL, &free);
-
- for(item= item_array; item->identifier; item++) {
- if(item->identifier[0] && strcmp(item->identifier, identifier)==0) {
- *value = item->value;
- break;
+
+ if(item_array) {
+ for(item= item_array; item->identifier; item++) {
+ if(item->identifier[0] && strcmp(item->identifier, identifier)==0) {
+ *value = item->value;
+ break;
+ }
}
- }
-
- found= (item->identifier != NULL); /* could be alloc'd, assign before free */
- if(free)
- MEM_freeN(item_array);
+ found= (item->identifier != NULL); /* could be alloc'd, assign before free */
+ if(free) {
+ MEM_freeN(item_array);
+ }
+ }
+ else {
+ found= 0;
+ }
return found;
}
@@ -4036,8 +4053,9 @@ int RNA_property_is_idprop(PropertyRNA *prop)
}
/* string representation of a property, python
- * compatible but can be used for display too*/
-char *RNA_pointer_as_string(PointerRNA *ptr)
+ * compatible but can be used for display too,
+ * context may be NULL */
+char *RNA_pointer_as_string(bContext *C, PointerRNA *ptr)
{
DynStr *dynstr= BLI_dynstr_new();
char *cstring;
@@ -4057,7 +4075,7 @@ char *RNA_pointer_as_string(PointerRNA *ptr)
BLI_dynstr_append(dynstr, ", ");
first_time= 0;
- cstring = RNA_property_as_string(NULL, ptr, prop);
+ cstring = RNA_property_as_string(C, ptr, prop);
BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring);
MEM_freeN(cstring);
}
@@ -4175,7 +4193,7 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
case PROP_POINTER:
{
PointerRNA tptr= RNA_property_pointer_get(ptr, prop);
- cstring= RNA_pointer_as_string(&tptr);
+ cstring= RNA_pointer_as_string(C, &tptr);
BLI_dynstr_append(dynstr, cstring);
MEM_freeN(cstring);
break;
@@ -4194,7 +4212,7 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
first_time= 0;
/* now get every prop of the collection */
- cstring= RNA_pointer_as_string(&itemptr);
+ cstring= RNA_pointer_as_string(C, &itemptr);
BLI_dynstr_append(dynstr, cstring);
MEM_freeN(cstring);
}
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 106c51865fd..7f817aa5b4b 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -188,7 +188,7 @@ static StructRNA *rna_KeyingSetInfo_refine(PointerRNA *ptr)
return (ksi->ext.srna)? ksi->ext.srna: &RNA_KeyingSetInfo;
}
-static void rna_KeyingSetInfo_unregister(const bContext *C, StructRNA *type)
+static void rna_KeyingSetInfo_unregister(Main *bmain, StructRNA *type)
{
KeyingSetInfo *ksi= RNA_struct_blender_type_get(type);
@@ -200,10 +200,10 @@ static void rna_KeyingSetInfo_unregister(const bContext *C, StructRNA *type)
RNA_struct_free(&BLENDER_RNA, type);
/* unlink Blender-side data */
- ANIM_keyingset_info_unregister(C, ksi);
+ ANIM_keyingset_info_unregister(bmain, ksi);
}
-static StructRNA *rna_KeyingSetInfo_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_KeyingSetInfo_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
KeyingSetInfo dummyksi = {NULL};
KeyingSetInfo *ksi;
@@ -226,7 +226,7 @@ static StructRNA *rna_KeyingSetInfo_register(bContext *C, ReportList *reports, v
/* check if we have registered this info before, and remove it */
ksi = ANIM_keyingset_info_find_named(dummyksi.idname);
if (ksi && ksi->ext.srna)
- rna_KeyingSetInfo_unregister(C, ksi->ext.srna);
+ rna_KeyingSetInfo_unregister(bmain, ksi->ext.srna);
/* create a new KeyingSetInfo type */
ksi= MEM_callocN(sizeof(KeyingSetInfo), "python keying set info");
@@ -509,7 +509,7 @@ static void rna_def_keyingset_info(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "KeyingSetInfo");
RNA_def_struct_ui_text(srna, "Keying Set Info", "Callback function defines for builtin Keying Sets");
RNA_def_struct_refine_func(srna, "rna_KeyingSetInfo_refine");
- RNA_def_struct_register_funcs(srna, "rna_KeyingSetInfo_register", "rna_KeyingSetInfo_unregister");
+ RNA_def_struct_register_funcs(srna, "rna_KeyingSetInfo_register", "rna_KeyingSetInfo_unregister", NULL);
/* Properties --------------------- */
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 3afec03a13f..d66f0042d88 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -813,7 +813,7 @@ void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
if(idproperties) srna->idproperties= (IDPropertiesFunc)idproperties;
}
-void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg)
+void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
{
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_struct_register_funcs: only during preprocessing.\n");
@@ -822,6 +822,7 @@ void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char
if(reg) srna->reg= (StructRegisterFunc)reg;
if(unreg) srna->unreg= (StructUnregisterFunc)unreg;
+ if(instance) srna->instance= (StructInstanceFunc)instance;
}
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 1d060c8a362..a9fb545ec3f 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -197,8 +197,8 @@ struct StructRNA *rna_ID_refine(struct PointerRNA *ptr);
struct IDProperty *rna_ID_idprops(struct PointerRNA *ptr, int create);
void rna_ID_fake_user_set(struct PointerRNA *ptr, int value);
struct IDProperty *rna_PropertyGroup_idprops(struct PointerRNA *ptr, int create);
-void rna_PropertyGroup_unregister(const struct bContext *C, struct StructRNA *type);
-struct StructRNA *rna_PropertyGroup_register(struct bContext *C, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free);
+void rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type);
+struct StructRNA *rna_PropertyGroup_register(struct Main *bmain, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free);
struct StructRNA* rna_PropertyGroup_refine(struct PointerRNA *ptr);
void rna_object_vgroup_name_index_get(struct PointerRNA *ptr, char *value, int index);
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index eb1beb90567..a59db183453 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -330,6 +330,7 @@ struct StructRNA {
/* function to register/unregister subclasses */
StructRegisterFunc reg;
StructUnregisterFunc unreg;
+ StructInstanceFunc instance;
/* callback to get id properties */
IDPropertiesFunc idproperties;
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index f87eb4ca4aa..da2704ab641 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -101,7 +101,7 @@ static void engine_render(RenderEngine *engine, struct Scene *scene)
RNA_parameter_list_free(&list);
}
-static void rna_RenderEngine_unregister(const bContext *C, StructRNA *type)
+static void rna_RenderEngine_unregister(Main *bmain, StructRNA *type)
{
RenderEngineType *et= RNA_struct_blender_type_get(type);
@@ -113,7 +113,7 @@ static void rna_RenderEngine_unregister(const bContext *C, StructRNA *type)
RNA_struct_free(&BLENDER_RNA, type);
}
-static StructRNA *rna_RenderEngine_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
RenderEngineType *et, dummyet = {NULL};
RenderEngine dummyengine= {NULL};
@@ -137,7 +137,7 @@ static StructRNA *rna_RenderEngine_register(bContext *C, ReportList *reports, vo
for(et=R_engines.first; et; et=et->next) {
if(strcmp(et->idname, dummyet.idname) == 0) {
if(et->ext.srna)
- rna_RenderEngine_unregister(C, et->ext.srna);
+ rna_RenderEngine_unregister(bmain, et->ext.srna);
break;
}
}
@@ -233,7 +233,7 @@ static void rna_def_render_engine(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "RenderEngine");
RNA_def_struct_ui_text(srna, "Render Engine", "Render engine");
RNA_def_struct_refine_func(srna, "rna_RenderEngine_refine");
- RNA_def_struct_register_funcs(srna, "rna_RenderEngine_register", "rna_RenderEngine_unregister");
+ RNA_def_struct_register_funcs(srna, "rna_RenderEngine_register", "rna_RenderEngine_unregister", NULL);
/* render */
func= RNA_def_function(srna, "render", NULL);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index bc429f47c3f..fadf69801f9 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2007,6 +2007,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
{RE_BAKE_NORMALS, "NORMALS", 0, "Normals", "Bake normals"},
{RE_BAKE_TEXTURE, "TEXTURE", 0, "Textures", "Bake textures"},
{RE_BAKE_DISPLACEMENT, "DISPLACEMENT", 0, "Displacement", "Bake displacement"},
+ {RE_BAKE_EMIT, "EMIT", 0, "Emission", "Bake Emit values (glow)"},
+ {RE_BAKE_ALPHA, "ALPHA", 0, "Alpha", "Bake Alpha values (transparency)"},
+ {RE_BAKE_MIRROR_INTENSITY, "MIRROR_INTENSITY", 0, "Mirror Intensity", "Bake Mirror values"},
+ {RE_BAKE_MIRROR_COLOR, "MIRROR_COLOR", 0, "Mirror Colors", "Bake Mirror colors"},
+ {RE_BAKE_SPEC_INTENSITY, "SPEC_INTENSITY", 0, "Specular Intensity", "Bake Specular values"},
+ {RE_BAKE_SPEC_COLOR, "SPEC_COLOR", 0, "Specular Colors", "Bake Specular colors"},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem bake_normal_space_items[] ={
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index d129fccc717..be4adb405e2 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -82,7 +82,7 @@ static void rna_Screen_scene_update(bContext *C, PointerRNA *ptr)
static void rna_Screen_redraw_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
bScreen *screen= (bScreen*)ptr->data;
-
+
/* the settings for this are currently only available from a menu in the TimeLine, hence refresh=SPACE_TIME */
ED_screen_animation_timer_update(screen, screen->redraws_flag, SPACE_TIME);
}
@@ -116,12 +116,29 @@ static void rna_Area_type_update(bContext *C, PointerRNA *ptr)
#else
+/* Area.spaces */
+static void rna_def_area_spaces(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ RNA_def_property_srna(cprop, "AreaSpaces");
+ srna= RNA_def_struct(brna, "AreaSpaces", NULL);
+ RNA_def_struct_sdna(srna, "ScrArea");
+ RNA_def_struct_ui_text(srna, "Area Spaces", "Collection of spaces");
+
+ prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "spacedata.first");
+ RNA_def_property_struct_type(prop, "Space");
+ RNA_def_property_ui_text(prop, "Active Space", "Space currently being displayed in this area");
+}
+
static void rna_def_area(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
FunctionRNA *func;
-
+
srna= RNA_def_struct(brna, "Area", NULL);
RNA_def_struct_ui_text(srna, "Area", "Area in a subdivided screen, containing an editor");
RNA_def_struct_sdna(srna, "ScrArea");
@@ -130,11 +147,7 @@ static void rna_def_area(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "spacedata", NULL);
RNA_def_property_struct_type(prop, "Space");
RNA_def_property_ui_text(prop, "Spaces", "Spaces contained in this area, the first being the active space. NOTE: Useful for example to restore a previously used 3d view space in a certain area to get the old view orientation.");
-
- prop= RNA_def_property(srna, "active_space", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "spacedata.first");
- RNA_def_property_struct_type(prop, "Space");
- RNA_def_property_ui_text(prop, "Active Space", "Space currently being displayed in this area");
+ rna_def_area_spaces(brna, prop);
prop= RNA_def_property(srna, "regions", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "regionbase", NULL);
@@ -144,7 +157,7 @@ static void rna_def_area(BlenderRNA *brna)
prop= RNA_def_property(srna, "show_menus", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", HEADER_NO_PULLDOWN);
RNA_def_property_ui_text(prop, "Show Menus", "Show menus in the header");
-
+
prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "spacetype");
RNA_def_property_enum_items(prop, space_type_items);
@@ -174,11 +187,11 @@ static void rna_def_region(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna= RNA_def_struct(brna, "Region", NULL);
RNA_def_struct_ui_text(srna, "Region", "Region in a subdivided screen area");
RNA_def_struct_sdna(srna, "ARegion");
-
+
prop= RNA_def_property(srna, "id", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "swinid");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -199,7 +212,7 @@ static void rna_def_region(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "winy");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Height", "Region height");
-
+
RNA_def_function(srna, "tag_redraw", "ED_region_tag_redraw");
}
@@ -207,12 +220,12 @@ static void rna_def_screen(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna= RNA_def_struct(brna, "Screen", "ID");
RNA_def_struct_sdna(srna, "Screen"); /* it is actually bScreen but for 2.5 the dna is patched! */
RNA_def_struct_ui_text(srna, "Screen", "Screen datablock, defining the layout of areas in a window");
RNA_def_struct_ui_icon(srna, ICON_SPLITSCREEN);
-
+
/* pointers */
prop= RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_NULL);
@@ -220,55 +233,55 @@ static void rna_def_screen(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the screen");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, 0, "rna_Screen_scene_update");
-
+
/* collections */
prop= RNA_def_property(srna, "areas", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "areabase", NULL);
RNA_def_property_struct_type(prop, "Area");
RNA_def_property_ui_text(prop, "Areas", "Areas the screen is subdivided into");
-
+
/* readonly status indicators */
prop= RNA_def_property(srna, "is_animation_playing", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_funcs(prop, "rna_Screen_is_animation_playing_get", NULL);
RNA_def_property_ui_text(prop, "Animation Playing", "Animation playback is active");
-
+
prop= RNA_def_property(srna, "show_fullscreen", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", NULL);
RNA_def_property_ui_text(prop, "Fullscreen", "An area is maximised, filling this screen");
-
+
/* Define Anim Playback Areas */
prop= RNA_def_property(srna, "use_play_top_left_3d_editor", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_REGION);
RNA_def_property_ui_text(prop, "Top-Left 3D Editor", "");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
-
+
prop= RNA_def_property(srna, "use_play_3d_editors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_3D_WIN);
RNA_def_property_ui_text(prop, "All 3D View Editors", "");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
-
+
prop= RNA_def_property(srna, "use_play_animation_editors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_ANIM_WIN);
RNA_def_property_ui_text(prop, "Animation Editors", "");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
-
+
prop= RNA_def_property(srna, "use_play_properties_editors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_BUTS_WIN);
RNA_def_property_ui_text(prop, "Property Editors", "");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
-
+
prop= RNA_def_property(srna, "use_play_image_editors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_IMAGE_WIN);
RNA_def_property_ui_text(prop, "Image Editors", "");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
-
+
prop= RNA_def_property(srna, "use_play_sequence_editors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_SEQ);
RNA_def_property_ui_text(prop, "Sequencer Editors", "");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
-
+
prop= RNA_def_property(srna, "use_play_node_editors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_NODES);
RNA_def_property_ui_text(prop, "Node Editors", "");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 2dbbb29f174..5d45a63b05b 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -110,6 +110,7 @@ EnumPropertyItem viewport_shade_items[] = {
#include "BLI_math.h"
+#include "BKE_screen.h"
#include "BKE_animsys.h"
#include "BKE_brush.h"
#include "BKE_colortools.h"
@@ -509,17 +510,12 @@ static void rna_SpaceImageEditor_zoom_get(PointerRNA *ptr, float *values)
values[0] = values[1] = 1;
- sa = rna_area_from_space(ptr);
- if(!sa) return;
-
/* find aregion */
- for(ar=sa->regionbase.first; ar; ar=ar->next) {
- if(ar->regiontype == RGN_TYPE_WINDOW)
- break;
+ sa= rna_area_from_space(ptr); /* can be NULL */
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if(ar) {
+ ED_space_image_zoom(sima, ar, &values[0], &values[1]);
}
- if(!ar) return;
-
- ED_space_image_zoom(sima, ar, &values[0], &values[1]);
}
static void rna_SpaceImageEditor_cursor_location_get(PointerRNA *ptr, float *values)
@@ -1435,6 +1431,11 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_enum_items(prop, rv3d_persp_items);
RNA_def_property_ui_text(prop, "Perspective", "View Perspective");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
+
+ prop= RNA_def_property(srna, "is_perspective", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "is_persp", 1);
+ RNA_def_property_ui_text(prop, "Is Perspective", "");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
prop= RNA_def_property(srna, "view_location", PROP_FLOAT, PROP_TRANSLATION);
#if 0
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index b5c6de679b2..13c7ac238a3 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -148,7 +148,7 @@ static void panel_draw_header(const bContext *C, Panel *pnl)
RNA_parameter_list_free(&list);
}
-static void rna_Panel_unregister(const bContext *C, StructRNA *type)
+static void rna_Panel_unregister(Main *bmain, StructRNA *type)
{
ARegionType *art;
PanelType *pt= RNA_struct_blender_type_get(type);
@@ -164,11 +164,10 @@ static void rna_Panel_unregister(const bContext *C, StructRNA *type)
RNA_struct_free(&BLENDER_RNA, type);
/* update while blender is running */
- if(C)
- WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
}
-static StructRNA *rna_Panel_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
ARegionType *art;
PanelType *pt, dummypt = {NULL};
@@ -196,7 +195,7 @@ static StructRNA *rna_Panel_register(bContext *C, ReportList *reports, void *dat
for(pt=art->paneltypes.first; pt; pt=pt->next) {
if(strcmp(pt->idname, dummypt.idname) == 0) {
if(pt->ext.srna)
- rna_Panel_unregister(C, pt->ext.srna);
+ rna_Panel_unregister(bmain, pt->ext.srna);
else
BLI_freelinkN(&art->paneltypes, pt);
break;
@@ -233,8 +232,7 @@ static StructRNA *rna_Panel_register(bContext *C, ReportList *reports, void *dat
BLI_addtail(&art->paneltypes, pt);
/* update while blender is running */
- if(C)
- WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
return pt->ext.srna;
}
@@ -263,7 +261,7 @@ static void header_draw(const bContext *C, Header *hdr)
RNA_parameter_list_free(&list);
}
-static void rna_Header_unregister(const bContext *C, StructRNA *type)
+static void rna_Header_unregister(Main *bmain, StructRNA *type)
{
ARegionType *art;
HeaderType *ht= RNA_struct_blender_type_get(type);
@@ -279,11 +277,10 @@ static void rna_Header_unregister(const bContext *C, StructRNA *type)
RNA_struct_free(&BLENDER_RNA, type);
/* update while blender is running */
- if(C)
- WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
}
-static StructRNA *rna_Header_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_Header_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
ARegionType *art;
HeaderType *ht, dummyht = {NULL};
@@ -311,7 +308,7 @@ static StructRNA *rna_Header_register(bContext *C, ReportList *reports, void *da
for(ht=art->headertypes.first; ht; ht=ht->next) {
if(strcmp(ht->idname, dummyht.idname) == 0) {
if(ht->ext.srna)
- rna_Header_unregister(C, ht->ext.srna);
+ rna_Header_unregister(bmain, ht->ext.srna);
break;
}
}
@@ -331,8 +328,7 @@ static StructRNA *rna_Header_register(bContext *C, ReportList *reports, void *da
BLI_addtail(&art->headertypes, ht);
/* update while blender is running */
- if(C)
- WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
return ht->ext.srna;
}
@@ -384,7 +380,7 @@ static void menu_draw(const bContext *C, Menu *hdr)
RNA_parameter_list_free(&list);
}
-static void rna_Menu_unregister(const bContext *C, StructRNA *type)
+static void rna_Menu_unregister(Main *bmain, StructRNA *type)
{
MenuType *mt= RNA_struct_blender_type_get(type);
@@ -398,11 +394,10 @@ static void rna_Menu_unregister(const bContext *C, StructRNA *type)
RNA_struct_free(&BLENDER_RNA, type);
/* update while blender is running */
- if(C)
- WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
}
-static StructRNA *rna_Menu_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_Menu_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
MenuType *mt, dummymt = {NULL};
Menu dummymenu= {NULL};
@@ -425,7 +420,7 @@ static StructRNA *rna_Menu_register(bContext *C, ReportList *reports, void *data
/* check if we have registered this menu type before, and remove it */
mt= WM_menutype_find(dummymt.idname, TRUE);
if(mt && mt->ext.srna)
- rna_Menu_unregister(C, mt->ext.srna);
+ rna_Menu_unregister(bmain, mt->ext.srna);
/* create a new menu type */
mt= MEM_callocN(sizeof(MenuType), "python buttons menu");
@@ -444,8 +439,7 @@ static StructRNA *rna_Menu_register(bContext *C, ReportList *reports, void *data
WM_menutype_add(mt);
/* update while blender is running */
- if(C)
- WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
return mt->ext.srna;
}
@@ -617,7 +611,7 @@ static void rna_def_panel(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Panel", "Panel containing UI elements");
RNA_def_struct_sdna(srna, "Panel");
RNA_def_struct_refine_func(srna, "rna_Panel_refine");
- RNA_def_struct_register_funcs(srna, "rna_Panel_register", "rna_Panel_unregister");
+ RNA_def_struct_register_funcs(srna, "rna_Panel_register", "rna_Panel_unregister", NULL);
/* poll */
func= RNA_def_function(srna, "poll", NULL);
@@ -694,7 +688,7 @@ static void rna_def_header(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Header", "Editor header containing UI elements.");
RNA_def_struct_sdna(srna, "Header");
RNA_def_struct_refine_func(srna, "rna_Header_refine");
- RNA_def_struct_register_funcs(srna, "rna_Header_register", "rna_Header_unregister");
+ RNA_def_struct_register_funcs(srna, "rna_Header_register", "rna_Header_unregister", NULL);
/* draw */
func= RNA_def_function(srna, "draw", NULL);
@@ -736,7 +730,7 @@ static void rna_def_menu(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Menu", "Editor menu containing buttons");
RNA_def_struct_sdna(srna, "Menu");
RNA_def_struct_refine_func(srna, "rna_Menu_refine");
- RNA_def_struct_register_funcs(srna, "rna_Menu_register", "rna_Menu_unregister");
+ RNA_def_struct_register_funcs(srna, "rna_Menu_register", "rna_Menu_unregister", NULL);
/* poll */
func= RNA_def_function(srna, "poll", NULL);
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 4c79c27e0de..e8b127b68bb 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -669,19 +669,20 @@ static void rna_wmClipboard_set(PointerRNA *ptr, const char *value)
}
#ifdef WITH_PYTHON
-static void rna_Operator_unregister(const bContext *C, StructRNA *type)
+static void rna_Operator_unregister(struct Main *bmain, StructRNA *type)
{
const char *idname;
wmOperatorType *ot= RNA_struct_blender_type_get(type);
+ wmWindowManager *wm;
if(!ot)
return;
/* update while blender is running */
- if(C) {
- WM_operator_stack_clear((bContext*)C);
- WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
- }
+ wm= bmain->wm.first;
+ if(wm)
+ WM_operator_stack_clear(wm);
+ WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
RNA_struct_free_extension(type, &ot->ext);
@@ -858,7 +859,7 @@ void macro_wrapper(wmOperatorType *ot, void *userdata);
static char _operator_idname[OP_MAX_TYPENAME];
static char _operator_name[OP_MAX_TYPENAME];
static char _operator_descr[1024];
-static StructRNA *rna_Operator_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
wmOperatorType dummyot = {NULL};
wmOperator dummyop= {NULL};
@@ -935,7 +936,7 @@ static StructRNA *rna_Operator_register(bContext *C, ReportList *reports, void *
{
wmOperatorType *ot= WM_operatortype_find(dummyot.idname, TRUE);
if(ot && ot->ext.srna)
- rna_Operator_unregister(C, ot->ext.srna);
+ rna_Operator_unregister(bmain, ot->ext.srna);
}
/* create a new menu type */
@@ -955,14 +956,18 @@ static StructRNA *rna_Operator_register(bContext *C, ReportList *reports, void *
WM_operatortype_append_ptr(operator_wrapper, (void *)&dummyot);
/* update while blender is running */
- if(C)
- WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
return dummyot.ext.srna;
}
+void **rna_Operator_instance(PointerRNA *ptr)
+{
+ wmOperator *op = ptr->data;
+ return &op->py_instance;
+}
-static StructRNA *rna_MacroOperator_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_MacroOperator_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
wmOperatorType dummyot = {NULL};
wmOperator dummyop= {NULL};
@@ -1006,7 +1011,7 @@ static StructRNA *rna_MacroOperator_register(bContext *C, ReportList *reports, v
{
wmOperatorType *ot= WM_operatortype_find(dummyot.idname, TRUE);
if(ot && ot->ext.srna)
- rna_Operator_unregister(C, ot->ext.srna);
+ rna_Operator_unregister(bmain, ot->ext.srna);
}
/* create a new menu type */
@@ -1021,8 +1026,7 @@ static StructRNA *rna_MacroOperator_register(bContext *C, ReportList *reports, v
WM_operatortype_append_macro_ptr(macro_wrapper, (void *)&dummyot);
/* update while blender is running */
- if(C)
- WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
return dummyot.ext.srna;
}
@@ -1161,7 +1165,7 @@ static void rna_def_operator(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "wmOperator");
RNA_def_struct_refine_func(srna, "rna_Operator_refine");
#ifdef WITH_PYTHON
- RNA_def_struct_register_funcs(srna, "rna_Operator_register", "rna_Operator_unregister");
+ RNA_def_struct_register_funcs(srna, "rna_Operator_register", "rna_Operator_unregister", "rna_Operator_instance");
#endif
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
@@ -1230,7 +1234,7 @@ static void rna_def_macro_operator(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "wmOperator");
RNA_def_struct_refine_func(srna, "rna_MacroOperator_refine");
#ifdef WITH_PYTHON
- RNA_def_struct_register_funcs(srna, "rna_MacroOperator_register", "rna_Operator_unregister");
+ RNA_def_struct_register_funcs(srna, "rna_MacroOperator_register", "rna_Operator_unregister", "rna_Operator_instance");
#endif
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index 48865d3ed5f..61b7de7183a 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -91,7 +91,7 @@ static int isDisabled(ModifierData *md, int useRenderParams)
return get_render_subsurf_level(&md->scene->r, levels) == 0;
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
+static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
DerivedMesh *derivedData,
int useRenderParams,
int isFinalCalc)
@@ -100,7 +100,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
DerivedMesh *result;
result = subsurf_make_derived_from_derived(derivedData, smd,
- useRenderParams, NULL, isFinalCalc, 0);
+ useRenderParams, NULL, isFinalCalc, 0, (ob->flag & OB_MODE_EDIT));
if(useRenderParams || !isFinalCalc) {
DerivedMesh *cddm= CDDM_copy(result, 0);
@@ -119,7 +119,7 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *UNUSED(ob),
DerivedMesh *result;
result = subsurf_make_derived_from_derived(derivedData, smd, 0,
- NULL, 0, 1);
+ NULL, 0, 1, 1);
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 6be1002bb00..afa914e869c 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -271,7 +271,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
/* if only one projector, project coords to UVs */
if(num_projectors == 1 && projectors[0].uci==NULL)
for(i = 0, co = coords; i < numVerts; ++i, ++co)
- mul_project_m4_v4(projectors[0].projmat, *co);
+ mul_project_m4_v3(projectors[0].projmat, *co);
mface = dm->getTessFaceArray(dm);
numFaces = dm->getNumTessFaces(dm);
@@ -345,11 +345,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
project_from_camera(tface->uv[3], coords[mf->v4], best_projector->uci);
}
else {
- mul_project_m4_v4(best_projector->projmat, co1);
- mul_project_m4_v4(best_projector->projmat, co2);
- mul_project_m4_v4(best_projector->projmat, co3);
+ mul_project_m4_v3(best_projector->projmat, co1);
+ mul_project_m4_v3(best_projector->projmat, co2);
+ mul_project_m4_v3(best_projector->projmat, co3);
if(mf->v4)
- mul_project_m4_v4(best_projector->projmat, co4);
+ mul_project_m4_v3(best_projector->projmat, co4);
/* apply transformed coords as UVs */
tface->uv[0][0] = co1[0];
diff --git a/source/blender/python/generic/mathutils_Matrix.c b/source/blender/python/generic/mathutils_Matrix.c
index 41d9626db16..2b9de49bf3f 100644
--- a/source/blender/python/generic/mathutils_Matrix.c
+++ b/source/blender/python/generic/mathutils_Matrix.c
@@ -1674,7 +1674,7 @@ static PyObject *Matrix_getColSize(MatrixObject *self, void *UNUSED(closure))
return PyLong_FromLong((long) self->col_size);
}
-static PyObject *Matrix_getMedianScale(MatrixObject *self, void *UNUSED(closure))
+static PyObject *Matrix_median_scale_get(MatrixObject *self, void *UNUSED(closure))
{
float mat[3][3];
@@ -1692,7 +1692,7 @@ static PyObject *Matrix_getMedianScale(MatrixObject *self, void *UNUSED(closure)
return PyFloat_FromDouble(mat3_to_scale(mat));
}
-static PyObject *Matrix_getIsNegative(MatrixObject *self, void *UNUSED(closure))
+static PyObject *Matrix_is_negative_get(MatrixObject *self, void *UNUSED(closure))
{
if(BaseMath_ReadCallback(self) == -1)
return NULL;
@@ -1708,6 +1708,21 @@ static PyObject *Matrix_getIsNegative(MatrixObject *self, void *UNUSED(closure))
}
}
+static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closure))
+{
+ if(BaseMath_ReadCallback(self) == -1)
+ return NULL;
+
+ /*must be 3-4 cols, 3-4 rows, square matrix*/
+ if(self->col_size == 4 && self->row_size == 4)
+ return PyBool_FromLong(is_orthogonal_m4((float (*)[4])self->contigPtr));
+ else if(self->col_size == 3 && self->row_size == 3)
+ return PyBool_FromLong(is_orthogonal_m3((float (*)[3])self->contigPtr));
+ else {
+ PyErr_SetString(PyExc_AttributeError, "Matrix.is_orthogonal: inappropriate matrix size - expects 3x3 or 4x4 matrix");
+ return NULL;
+ }
+}
/*****************************************************************************/
/* Python attributes get/set structure: */
@@ -1715,8 +1730,9 @@ static PyObject *Matrix_getIsNegative(MatrixObject *self, void *UNUSED(closure))
static PyGetSetDef Matrix_getseters[] = {
{(char *)"row_size", (getter)Matrix_getRowSize, (setter)NULL, (char *)"The row size of the matrix (readonly).\n\n:type: int", NULL},
{(char *)"col_size", (getter)Matrix_getColSize, (setter)NULL, (char *)"The column size of the matrix (readonly).\n\n:type: int", NULL},
- {(char *)"median_scale", (getter)Matrix_getMedianScale, (setter)NULL, (char *)"The average scale applied to each axis (readonly).\n\n:type: float", NULL},
- {(char *)"is_negative", (getter)Matrix_getIsNegative, (setter)NULL, (char *)"True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL},
+ {(char *)"median_scale", (getter)Matrix_median_scale_get, (setter)NULL, (char *)"The average scale applied to each axis (readonly).\n\n:type: float", NULL},
+ {(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, (char *)"True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL},
+ {(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, (char *)"True if this matrix is orthogonal, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL},
{(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL},
{(char *)"owner",(getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
diff --git a/source/blender/python/generic/mathutils_geometry.c b/source/blender/python/generic/mathutils_geometry.c
index 6031c716807..49b5eff3aa8 100644
--- a/source/blender/python/generic/mathutils_geometry.c
+++ b/source/blender/python/generic/mathutils_geometry.c
@@ -497,6 +497,60 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj
}
+static char M_Geometry_intersect_line_plane_doc[] =
+".. function:: intersect_line_plane(line_a, line_b, plane_co, plane_no, no_flip=False)\n"
+"\n"
+" Takes 2 lines (as 4 vectors) and returns a vector for their point of intersection or None.\n"
+"\n"
+" :arg line_a: First point of the first line\n"
+" :type line_a: :class:`mathutils.Vector`\n"
+" :arg line_b: Second point of the first line\n"
+" :type line_b: :class:`mathutils.Vector`\n"
+" :arg plane_co: A point on the plane\n"
+" :type plane_co: :class:`mathutils.Vector`\n"
+" :arg plane_no: The direction the plane is facing\n"
+" :type plane_no: :class:`mathutils.Vector`\n"
+" :arg no_flip: Always return an intersection on the directon defined bt line_a -> line_b\n"
+" :type no_flip: :boolean\n"
+" :return: The point of intersection or None when not found\n"
+" :rtype: :class:`mathutils.Vector` or None\n"
+;
+static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObject* args)
+{
+ VectorObject *line_a, *line_b, *plane_co, *plane_no;
+ int no_flip= 0;
+ float isect[3];
+ if(!PyArg_ParseTuple(args, "O!O!O!O!|i:intersect_line_line_2d",
+ &vector_Type, &line_a,
+ &vector_Type, &line_b,
+ &vector_Type, &plane_co,
+ &vector_Type, &plane_no,
+ &no_flip)
+ ) {
+ return NULL;
+ }
+
+ if( BaseMath_ReadCallback(line_a) == -1 ||
+ BaseMath_ReadCallback(line_b) == -1 ||
+ BaseMath_ReadCallback(plane_co) == -1 ||
+ BaseMath_ReadCallback(plane_no) == -1
+ ) {
+ return NULL;
+ }
+
+ if(ELEM4(2, line_a->size, line_b->size, plane_co->size, plane_no->size)) {
+ PyErr_SetString(PyExc_RuntimeError, "geometry.intersect_line_plane(...) can't use 2D Vectors");
+ return NULL;
+ }
+
+ if(isect_line_plane_v3(isect, line_a->vec, line_b->vec, plane_co->vec, plane_no->vec, no_flip) == 1) {
+ return newVectorObject(isect, 3, Py_NEW, NULL);
+ }
+ else {
+ Py_RETURN_NONE;
+ }
+}
+
static char M_Geometry_intersect_point_line_doc[] =
".. function:: intersect_point_line(pt, line_p1, line_p2)\n"
"\n"
@@ -860,6 +914,7 @@ static PyMethodDef M_Geometry_methods[]= {
{"intersect_point_quad_2d", (PyCFunction) M_Geometry_intersect_point_quad_2d, METH_VARARGS, M_Geometry_intersect_point_quad_2d_doc},
{"intersect_line_line", (PyCFunction) M_Geometry_intersect_line_line, METH_VARARGS, M_Geometry_intersect_line_line_doc},
{"intersect_line_line_2d", (PyCFunction) M_Geometry_intersect_line_line_2d, METH_VARARGS, M_Geometry_intersect_line_line_2d_doc},
+ {"intersect_line_plane", (PyCFunction) M_Geometry_intersect_line_plane, METH_VARARGS, M_Geometry_intersect_line_plane_doc},
{"interpolate_bezier", (PyCFunction) M_Geometry_interpolate_bezier, METH_VARARGS, M_Geometry_interpolate_bezier_doc},
{"area_tri", (PyCFunction) M_Geometry_area_tri, METH_VARARGS, M_Geometry_area_tri_doc},
{"normal", (PyCFunction) M_Geometry_normal, METH_VARARGS, M_Geometry_normal_doc},
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 8af0db6ee13..4f62c545a71 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -6040,17 +6040,18 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
bpy_context_set(C, &gilstate);
if (!is_static) {
- /* exception, operators store their PyObjects for re-use */
+ /* some datatypes (operator, render engine) can store PyObjects for re-use */
if(ptr->data) {
- if(RNA_struct_is_a(ptr->type, &RNA_Operator)) {
- wmOperator *op= ptr->data;
- if(op->py_instance) {
- py_class_instance= op->py_instance;
+ void **instance = RNA_struct_instance(ptr);
+
+ if(instance) {
+ if(*instance) {
+ py_class_instance= *instance;
Py_INCREF(py_class_instance);
}
else {
/* store the instance here once its created */
- py_class_instance_store= &op->py_instance;
+ py_class_instance_store= instance;
}
}
}
@@ -6418,7 +6419,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
identifier= ((PyTypeObject*)py_class)->tp_name;
- srna_new= reg(C, &reports, py_class, identifier, bpy_class_validate, bpy_class_call, bpy_class_free);
+ srna_new= reg(CTX_data_main(C), &reports, py_class, identifier, bpy_class_validate, bpy_class_call, bpy_class_free);
if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
return NULL;
@@ -6568,7 +6569,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
C= BPy_GetContext();
/* call unregister */
- unreg(C, srna); /* calls bpy_class_free, this decref's py_class */
+ unreg(CTX_data_main(C), srna); /* calls bpy_class_free, this decref's py_class */
PyDict_DelItemString(((PyTypeObject *)py_class)->tp_dict, "bl_rna");
if(PyErr_Occurred())
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h
index 145d86575d0..47230ab3089 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -250,13 +250,19 @@ float RE_filter_value(int type, float x);
void RE_zbuf_accumulate_vecblur(struct NodeBlurData *nbd, int xsize, int ysize, float *newrect, float *imgrect, float *vecbufrect, float *zbufrect);
/* shaded view or baking options */
-#define RE_BAKE_LIGHT 0
-#define RE_BAKE_ALL 1
-#define RE_BAKE_AO 2
-#define RE_BAKE_NORMALS 3
-#define RE_BAKE_TEXTURE 4
-#define RE_BAKE_DISPLACEMENT 5
-#define RE_BAKE_SHADOW 6
+#define RE_BAKE_LIGHT 0 /* not listed in rna_scene.c -> can't be enabled! */
+#define RE_BAKE_ALL 1
+#define RE_BAKE_AO 2
+#define RE_BAKE_NORMALS 3
+#define RE_BAKE_TEXTURE 4
+#define RE_BAKE_DISPLACEMENT 5
+#define RE_BAKE_SHADOW 6
+#define RE_BAKE_SPEC_COLOR 7
+#define RE_BAKE_SPEC_INTENSITY 8
+#define RE_BAKE_MIRROR_COLOR 9
+#define RE_BAKE_MIRROR_INTENSITY 10
+#define RE_BAKE_ALPHA 11
+#define RE_BAKE_EMIT 12
void RE_Database_Baking(struct Render *re, struct Main *bmain, struct Scene *scene, unsigned int lay, int type, struct Object *actob);
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 7a34fc0af50..bc6c4795f5c 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -2143,7 +2143,9 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int quad, int
shade_input_set_shade_texco(shi);
- if(!ELEM3(bs->type, RE_BAKE_NORMALS, RE_BAKE_TEXTURE, RE_BAKE_SHADOW))
+ /* only do AO for a full bake (and obviously AO bakes)
+ AO for light bakes is a leftover and might not be needed */
+ if( ELEM3(bs->type, RE_BAKE_ALL, RE_BAKE_AO, RE_BAKE_LIGHT))
shade_samples_do_AO(ssamp);
if(shi->mat->nodetree && shi->mat->use_nodes) {
@@ -2206,6 +2208,42 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int quad, int
VECCOPY(shr.combined, shr.shad);
shr.alpha = shi->alpha;
}
+ else if(bs->type==RE_BAKE_SPEC_COLOR) {
+ shr.combined[0]= shi->specr;
+ shr.combined[1]= shi->specg;
+ shr.combined[2]= shi->specb;
+ shr.alpha = 1.0f;
+ }
+ else if(bs->type==RE_BAKE_SPEC_INTENSITY) {
+ shr.combined[0]=
+ shr.combined[1]=
+ shr.combined[2]= shi->spec;
+ shr.alpha = 1.0f;
+ }
+ else if(bs->type==RE_BAKE_MIRROR_COLOR) {
+ shr.combined[0]= shi->mirr;
+ shr.combined[1]= shi->mirg;
+ shr.combined[2]= shi->mirb;
+ shr.alpha = 1.0f;
+ }
+ else if(bs->type==RE_BAKE_MIRROR_INTENSITY) {
+ shr.combined[0]=
+ shr.combined[1]=
+ shr.combined[2]= shi->ray_mirror;
+ shr.alpha = 1.0f;
+ }
+ else if(bs->type==RE_BAKE_ALPHA) {
+ shr.combined[0]=
+ shr.combined[1]=
+ shr.combined[2]= shi->alpha;
+ shr.alpha = 1.0f;
+ }
+ else if(bs->type==RE_BAKE_EMIT) {
+ shr.combined[0]=
+ shr.combined[1]=
+ shr.combined[2]= shi->emit;
+ shr.alpha = 1.0f;
+ }
}
if(bs->rect_float) {
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 58645f48787..e08e681f494 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -95,7 +95,7 @@ void WM_window_open_temp (struct bContext *C, struct rcti *position, int type);
int WM_read_homefile_exec(struct bContext *C, struct wmOperator *op);
int WM_read_homefile (struct bContext *C, struct ReportList *reports, short from_memory);
int WM_write_homefile (struct bContext *C, struct wmOperator *op);
-void WM_read_file (struct bContext *C, const char *name, struct ReportList *reports);
+void WM_read_file (struct bContext *C, const char *filepath, struct ReportList *reports);
int WM_write_file (struct bContext *C, const char *target, int fileflags, struct ReportList *reports, int copy);
void WM_read_autosavefile(struct bContext *C);
void WM_autosave_init (struct wmWindowManager *wm);
@@ -216,7 +216,7 @@ int WM_operator_confirm_message(struct bContext *C, struct wmOperator *op, con
/* operator api */
void WM_operator_free (struct wmOperator *op);
-void WM_operator_stack_clear(struct bContext *C);
+void WM_operator_stack_clear(struct wmWindowManager *wm);
struct wmOperatorType *WM_operatortype_find(const char *idnamem, int quiet);
struct wmOperatorType *WM_operatortype_first(void);
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 424c13f089f..bcd5cf38f88 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -137,9 +137,8 @@ void wm_operator_register(bContext *C, wmOperator *op)
}
-void WM_operator_stack_clear(bContext *C)
+void WM_operator_stack_clear(wmWindowManager *wm)
{
- wmWindowManager *wm= CTX_wm_manager(C);
wmOperator *op;
while((op= wm->operators.first)) {
@@ -147,7 +146,7 @@ void WM_operator_stack_clear(bContext *C)
WM_operator_free(op);
}
- WM_event_add_notifier(C, NC_WM|ND_HISTORY, NULL);
+ WM_main_add_notifier(NC_WM|ND_HISTORY, NULL);
}
/* ****************************************** */
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 2783504ae90..ea77fca4712 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -333,7 +333,7 @@ static int wm_read_exotic(Scene *UNUSED(scene), const char *name)
return retval;
}
-void WM_read_file(bContext *C, const char *name, ReportList *reports)
+void WM_read_file(bContext *C, const char *filepath, ReportList *reports)
{
int retval;
@@ -345,7 +345,7 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports)
/* first try to append data from exotic file formats... */
/* it throws error box when file doesnt exist and returns -1 */
/* note; it should set some error message somewhere... (ton) */
- retval= wm_read_exotic(CTX_data_scene(C), name);
+ retval= wm_read_exotic(CTX_data_scene(C), filepath);
/* we didn't succeed, now try to read Blender file */
if (retval == BKE_READ_EXOTIC_OK_BLEND) {
@@ -356,7 +356,7 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports)
/* also exit screens and editors */
wm_window_match_init(C, &wmbase);
- retval= BKE_read_file(C, name, reports);
+ retval= BKE_read_file(C, filepath, reports);
G.save_over = 1;
/* this flag is initialized by the operator but overwritten on read.
@@ -416,16 +416,16 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports)
else if(retval == BKE_READ_EXOTIC_OK_OTHER)
BKE_write_undo(C, "Import file");
else if(retval == BKE_READ_EXOTIC_FAIL_OPEN) {
- BKE_reportf(reports, RPT_ERROR, "Can't read file: \"%s\", %s.", name, errno ? strerror(errno) : "Unable to open the file");
+ BKE_reportf(reports, RPT_ERROR, "Can't read file: \"%s\", %s.", filepath, errno ? strerror(errno) : "Unable to open the file");
}
else if(retval == BKE_READ_EXOTIC_FAIL_FORMAT) {
- BKE_reportf(reports, RPT_ERROR, "File format is not supported in file: \"%s\".", name);
+ BKE_reportf(reports, RPT_ERROR, "File format is not supported in file: \"%s\".", filepath);
}
else if(retval == BKE_READ_EXOTIC_FAIL_PATH) {
- BKE_reportf(reports, RPT_ERROR, "File path invalid: \"%s\".", name);
+ BKE_reportf(reports, RPT_ERROR, "File path invalid: \"%s\".", filepath);
}
else {
- BKE_reportf(reports, RPT_ERROR, "Unknown error loading: \"%s\".", name);
+ BKE_reportf(reports, RPT_ERROR, "Unknown error loading: \"%s\".", filepath);
BLI_assert(!"invalid 'retval'");
}
@@ -709,7 +709,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
{
Library *li;
int len;
- char di[FILE_MAX];
+ char filepath[FILE_MAX];
int *thumb= NULL;
ImBuf *ibuf_thumb= NULL;
@@ -726,14 +726,14 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
return -1;
}
- BLI_strncpy(di, target, FILE_MAX);
- BLI_replace_extension(di, FILE_MAX, ".blend");
+ BLI_strncpy(filepath, target, FILE_MAX);
+ BLI_replace_extension(filepath, FILE_MAX, ".blend");
/* dont use 'target' anymore */
/* send the OnSave event */
for (li= G.main->library.first; li; li= li->id.next) {
- if (BLI_path_cmp(li->filepath, di) == 0) {
- BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.200s'", di);
+ if (BLI_path_cmp(li->filepath, filepath) == 0) {
+ BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.200s'", filepath);
return -1;
}
}
@@ -754,12 +754,12 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
ibuf_thumb= blend_file_thumb(CTX_data_scene(C), &thumb);
/* rename to .blend1, do this as last before write */
- do_history(di, reports);
+ do_history(filepath, reports);
- if (BLO_write_file(CTX_data_main(C), di, fileflags, reports, thumb)) {
+ if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) {
if(!copy) {
G.relbase_valid = 1;
- BLI_strncpy(G.main->name, di, sizeof(G.main->name)); /* is guaranteed current file */
+ BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); /* is guaranteed current file */
G.save_over = 1; /* disable untitled.blend convention */
}
@@ -774,7 +774,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
/* run this function after because the file cant be written before the blend is */
if (ibuf_thumb) {
- ibuf_thumb= IMB_thumb_create(di, THB_NORMAL, THB_SOURCE_BLEND, ibuf_thumb);
+ ibuf_thumb= IMB_thumb_create(filepath, THB_NORMAL, THB_SOURCE_BLEND, ibuf_thumb);
IMB_freeImBuf(ibuf_thumb);
}
@@ -798,20 +798,20 @@ int WM_write_homefile(bContext *C, wmOperator *op)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindow *win= CTX_wm_window(C);
- char tstr[FILE_MAXDIR+FILE_MAXFILE];
+ char filepath[FILE_MAXDIR+FILE_MAXFILE];
int fileflags;
/* check current window and close it if temp */
if(win->screen->temp)
wm_window_close(C, wm, win);
- BLI_make_file_string("/", tstr, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
- printf("trying to save homefile at %s ", tstr);
+ BLI_make_file_string("/", filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
+ printf("trying to save homefile at %s ", filepath);
/* force save as regular blend file */
fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN);
- if(BLO_write_file(CTX_data_main(C), tstr, fileflags, op->reports, NULL) == 0) {
+ if(BLO_write_file(CTX_data_main(C), filepath, fileflags, op->reports, NULL) == 0) {
printf("fail\n");
return OPERATOR_CANCELLED;
}
@@ -825,7 +825,7 @@ int WM_write_homefile(bContext *C, wmOperator *op)
/************************ autosave ****************************/
-void wm_autosave_location(char *filename)
+void wm_autosave_location(char *filepath)
{
char pidstr[32];
#ifdef WIN32
@@ -845,12 +845,12 @@ void wm_autosave_location(char *filename)
* If there is no C:\tmp autosave fails. */
if (!BLI_exists(U.tempdir)) {
savedir = BLI_get_folder_create(BLENDER_USER_AUTOSAVE, NULL);
- BLI_make_file_string("/", filename, savedir, pidstr);
+ BLI_make_file_string("/", filepath, savedir, pidstr);
return;
}
#endif
- BLI_make_file_string("/", filename, U.tempdir, pidstr);
+ BLI_make_file_string("/", filepath, U.tempdir, pidstr);
}
void WM_autosave_init(wmWindowManager *wm)
@@ -865,7 +865,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
{
wmWindow *win;
wmEventHandler *handler;
- char filename[FILE_MAX];
+ char filepath[FILE_MAX];
int fileflags;
WM_event_remove_timer(wm, NULL, wm->autosavetimer);
@@ -880,13 +880,13 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
}
}
- wm_autosave_location(filename);
+ wm_autosave_location(filepath);
/* force save as regular blend file */
fileflags = G.fileflags & ~(G_FILE_COMPRESS|G_FILE_AUTOPLAY |G_FILE_LOCK|G_FILE_SIGN);
/* no error reporting to console */
- BLO_write_file(CTX_data_main(C), filename, fileflags, NULL, NULL);
+ BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL);
/* do timer after file write, just in case file write takes a long time */
wm->autosavetimer= WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime*60.0);
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 2a37654a23b..57c3e2e233c 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -48,6 +48,7 @@
#include "BKE_blender.h"
#include "BKE_context.h"
+#include "BKE_screen.h"
#include "BKE_curve.h"
#include "BKE_displist.h"
#include "BKE_DerivedMesh.h"
@@ -248,15 +249,7 @@ int WM_init_game(bContext *C)
CTX_wm_window_set(C, win);
sa = biggest_view3d(C);
-
- if(sa)
- {
- for(ar=sa->regionbase.first; ar; ar=ar->next) {
- if(ar->regiontype == RGN_TYPE_WINDOW) {
- break;
- }
- }
- }
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
// if we have a valid 3D view
if (sa && ar) {
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 336acd9f9bf..1720c738dd7 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -493,17 +493,17 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, const char *op
}
else if(ELEM(opcontext, WM_OP_EXEC_REGION_CHANNELS, WM_OP_INVOKE_REGION_CHANNELS)) {
if (!(ar && ar->regiontype == RGN_TYPE_CHANNELS))
- ar= BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS);
-
- if(ar)
- found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS);
+
+ if(ar)
+ found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
}
else if(ELEM(opcontext, WM_OP_EXEC_REGION_PREVIEW, WM_OP_INVOKE_REGION_PREVIEW)) {
if (!(ar && ar->regiontype == RGN_TYPE_PREVIEW))
- ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
-
- if(ar)
- found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
+
+ if(ar)
+ found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
}
else {
if(ar)
diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h
index f73652125b1..fd279c31f3c 100644
--- a/source/blender/windowmanager/wm.h
+++ b/source/blender/windowmanager/wm.h
@@ -78,7 +78,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt);
void wm_autosave_timer_ended(wmWindowManager *wm);
void wm_autosave_delete(void);
void wm_autosave_read(bContext *C, struct ReportList *reports);
-void wm_autosave_location(char *filename);
+void wm_autosave_location(char *filepath);
/* hack to store circle select size - campbell, must replace with nice operator memory */
#define GESTURE_MEMORY
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 4789155dced..59c5888ff35 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -81,6 +81,8 @@ extern "C" {
#include "DNA_windowmanager_types.h"
#include "BKE_global.h"
#include "BKE_report.h"
+/* #include "BKE_screen.h" */ /* cant include this because of 'new' function name */
+extern float BKE_screen_view3d_zoom_to_fac(float camzoom);
//XXX #include "BIF_screen.h"
@@ -254,9 +256,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
camzoom = 1.0f;
}
else {
- camzoom = (1.41421 + (rv3d->camzoom / 50.0));
- camzoom *= camzoom;
- camzoom = 4.0 / camzoom;
+ camzoom = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom);
}
}
else {
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 0e0f617bddf..162c5ad4d44 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -143,9 +143,11 @@ extern "C" {
#include "BKE_customdata.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_material.h" /* give_current_material */
+
+extern Material defmaterial; /* material.c */
}
-#include "BKE_material.h" /* give_current_material */
/* end of blender include block */
#include "KX_BlenderInputDevice.h"
@@ -839,7 +841,6 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene,
/* ckeck for texface since texface _only_ is used as a fallback */
if(ma == NULL && tface == NULL) {
- extern Material defmaterial; /* material.c */
ma= &defmaterial;
}
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
index 832cd8b0651..75181b6c330 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
@@ -345,7 +345,9 @@ int main(int argc, char** argv)
bool fullScreen = false;
bool fullScreenParFound = false;
bool windowParFound = false;
+#ifdef WIN32
bool closeConsole = true;
+#endif
RAS_IRasterizer::StereoMode stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
bool stereoWindow = false;
bool stereoParFound = false;
@@ -570,7 +572,9 @@ int main(int argc, char** argv)
break;
case 'c':
i++;
+#ifdef WIN32
closeConsole = false;
+#endif
break;
case 's': // stereo
i++;