diff options
353 files changed, 2993 insertions, 3392 deletions
diff --git a/GNUmakefile b/GNUmakefile index b06344ca238..640e90de74b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -135,9 +135,6 @@ help: @echo " * package_pacman - build an arch linux pacmanpackage" @echo " * package_archive - build an archive package" @echo "" - @echo "Other Targets (not assosiated with building blender)" - @echo " * translations - update blenders translation files in po/" - @echo "" @echo "Testing Targets (not assosiated with building blender)" @echo " * test - run ctest, currently tests import/export, operator execution and that python modules load" @echo " * test_cmake - runs our own cmake file checker which detects errors in the cmake file list definitions" @@ -151,6 +148,7 @@ help: @echo "" @echo "Documentation Targets (not assosiated with building blender)" @echo " * doc_py - generate sphinx python api docs" + @echo " * doc_doxy - generate doxygen C/C++ docs" @echo " * doc_dna - generate blender file format reference" @echo " * doc_man - generate manpage" @echo "" @@ -170,16 +168,6 @@ package_archive: # ----------------------------------------------------------------------------- -# Other Targets -# -translations: - $(BUILD_DIR)/bin/blender --background -noaudio --factory-startup --python po/update_msg.py - python3 po/update_pot.py - python3 po/update_po.py - python3 po/update_mo.py - - -# ----------------------------------------------------------------------------- # Tests # test: @@ -238,9 +226,13 @@ check_sparse: # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation. doc_py: $(BUILD_DIR)/bin/blender --background -noaudio --factory-startup --python doc/python_api/sphinx_doc_gen.py - cd doc/python_api ; sphinx-build -n -b html sphinx-in sphinx-out + cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/contents.html'" +doc_doxy: + cd doc/doxygen; doxygen + @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'" + doc_dna: $(BUILD_DIR)/bin/blender --background -noaudio --factory-startup --python doc/blender_file_format/BlendFileDnaExporter_25.py @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'" diff --git a/build_files/cmake/project_info.py b/build_files/cmake/project_info.py index da1f2087f4f..eed002ce7ba 100755 --- a/build_files/cmake/project_info.py +++ b/build_files/cmake/project_info.py @@ -234,4 +234,3 @@ def project_name_get(path, fallback="Blender", prefix="Blender_"): if "/branches/" in l: return prefix + l.rsplit("/branches/", 1)[-1].split("/", 1)[0] return fallback - diff --git a/doc/doxygen/Doxyfile b/doc/doxygen/Doxyfile index b4d3b14b9dd..e8fb065e7a4 100644 --- a/doc/doxygen/Doxyfile +++ b/doc/doxygen/Doxyfile @@ -44,7 +44,7 @@ PROJECT_BRIEF = # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. -PROJECT_LOGO = ../../release/freedesktop/icons/48x48/blender.png +PROJECT_LOGO = ../../release/freedesktop/icons/48x48/apps/blender.png # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. @@ -193,7 +193,7 @@ SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. -TAB_SIZE = 8 +TAB_SIZE = 4 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". diff --git a/doc/doxygen/doxygen.source b/doc/doxygen/doxygen.source index 375234d26a3..cc3a2b14a92 100644 --- a/doc/doxygen/doxygen.source +++ b/doc/doxygen/doxygen.source @@ -22,6 +22,10 @@ * \ingroup python */ +/** \defgroup pymathutils Python Mathutils + * \ingroup python + */ + /** \defgroup pythonintern Python RNA and Operators * \ingroup python */ diff --git a/doc/python_api/examples/bpy.app.handlers.1.py b/doc/python_api/examples/bpy.app.handlers.1.py new file mode 100644 index 00000000000..a6591f6b83f --- /dev/null +++ b/doc/python_api/examples/bpy.app.handlers.1.py @@ -0,0 +1,20 @@ +""" +Persistent Handler Example +++++++++++++++++++++++++++ + +By default handlers are freed when loading new files, in some cases you may +wan't the handler stay running across multiple files (when the handler is +part of an addon for example). + +For this the :data:`bpy.app.handlers.persistent` decorator needs to be used. +""" + +import bpy +from bpy.app.handlers import persistent + + +@persistent +def load_handler(dummy): + print("Load Handler:", bpy.data.filepath) + +bpy.app.handlers.load_post.append(load_handler) diff --git a/doc/python_api/examples/bpy.app.handlers.py b/doc/python_api/examples/bpy.app.handlers.py new file mode 100644 index 00000000000..7c176063b7c --- /dev/null +++ b/doc/python_api/examples/bpy.app.handlers.py @@ -0,0 +1,12 @@ +""" +Basic Handler Example ++++++++++++++++++++++ +This script shows the most simple example of adding a handler. +""" + +import bpy + +def my_handler(scene): + print("Frame Change", scene.frame_current) + +bpy.app.handlers.frame_change_pre.append(my_handler)
\ No newline at end of file diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 5843e5ddb6c..36e092f85b7 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -50,7 +50,7 @@ For PDF generation # Check we're running in blender if __import__("sys").modules.get("bpy") is None: - print("\nError, this script must run from inside blender2.5") + print("\nError, this script must run from inside blender") print(script_help_msg) import sys @@ -70,13 +70,14 @@ else: # for testing so doc-builds dont take so long. EXCLUDE_MODULES = ( "bpy.context", - "bpy.app", + #"bpy.app", + #"bpy.app.handlers", "bpy.path", "bpy.data", "bpy.props", "bpy.utils", "bpy.context", - # "bpy.types", # supports filtering + "bpy.types", # supports filtering "bpy.ops", # supports filtering "bpy_extras", "bge", @@ -109,8 +110,18 @@ INFO_DOCS = ( ("info_gotcha.rst", "Gotcha's: some of the problems you may come up against when writing scripts"), ) -# import rpdb2; rpdb2.start_embedded_debugger('test') +# ----------------------------------------------------------------------------- +# configure compile time options + +try: + __import__("aud") +except ImportError: + print("Warning: Built without 'aud' module, docs incomplete...") + EXCLUDE_MODULES = EXCLUDE_MODULES + ("aud", ) + + +# import rpdb2; rpdb2.start_embedded_debugger('test') import os import inspect import bpy @@ -120,6 +131,7 @@ import rna_info ClassMethodDescriptorType = type(dict.__dict__['fromkeys']) MethodDescriptorType = type(dict.get) GetSetDescriptorType = type(int.real) +from types import MemberDescriptorType EXAMPLE_SET = set() EXAMPLE_SET_USED = set() @@ -134,6 +146,10 @@ else: _BPY_PROP_COLLECTION_ID = "collection" +def is_struct_seq(value): + return isinstance(value, tuple) and type(tuple) != tuple and hasattr(value, "n_fields") + + def undocumented_message(module_name, type_name, identifier): if str(type_name).startswith('<module'): preloadtitle = '%s.%s' % (module_name, identifier) @@ -305,6 +321,10 @@ def py_descr2sphinx(ident, fw, descr, module_name, type_name, identifier): fw(ident + ".. attribute:: %s\n\n" % identifier) write_indented_lines(ident + " ", fw, doc, False) fw("\n") + elif type(descr) == MemberDescriptorType: # same as above but use 'data' + fw(ident + ".. data:: %s\n\n" % identifier) + write_indented_lines(ident + " ", fw, doc, False) + fw("\n") elif type(descr) in (MethodDescriptorType, ClassMethodDescriptorType): write_indented_lines(ident, fw, doc, False) fw("\n") @@ -411,59 +431,90 @@ def pymodule2sphinx(BASEPATH, module_name, module, title): if key.startswith("__"): continue # naughty, we also add getset's into PyStructs, this is not typical py but also not incorrect. - if type(descr) == types.GetSetDescriptorType: # 'bpy_app_type' name is only used for examples and messages - py_descr2sphinx("", fw, descr, module_name, "bpy_app_type", key) + + # type_name is only used for examples and messages + type_name = str(type(module)).strip("<>").split(" ", 1)[-1][1:-1] # "<class 'bpy.app.handlers'>" --> bpy.app.handlers + if type(descr) == types.GetSetDescriptorType: + py_descr2sphinx("", fw, descr, module_name, type_name, key) attribute_set.add(key) + descr_sorted = [] for key, descr in sorted(type(module).__dict__.items()): if key.startswith("__"): continue - if type(descr) == types.MemberDescriptorType: + if type(descr) == MemberDescriptorType: if descr.__doc__: - fw(".. data:: %s\n\n" % key) - write_indented_lines(" ", fw, descr.__doc__, False) - fw("\n") - attribute_set.add(key) + value = getattr(module, key, None) + + value_type = type(value) + descr_sorted.append((key, descr, value, type(value))) + # sort by the valye type + descr_sorted.sort(key=lambda descr_data: str(descr_data[3])) + for key, descr, value, value_type in descr_sorted: + + # must be documented as a submodule + if is_struct_seq(value): + continue + + type_name = value_type.__name__ + py_descr2sphinx("", fw, descr, module_name, type_name, key) + + attribute_set.add(key) - del key, descr + del key, descr, descr_sorted classes = [] submodules = [] + # use this list so we can sort by type + module_dir_value_type = [] + for attribute in module_dir: - if not attribute.startswith("_"): - if attribute in attribute_set: - continue + if attribute.startswith("_"): + continue - if attribute.startswith("n_"): # annoying exception, needed for bpy.app - continue + if attribute in attribute_set: + continue - value = getattr(module, attribute) - - value_type = type(value) - - if value_type == types.FunctionType: - pyfunc2sphinx("", fw, attribute, value, is_class=False) - elif value_type in (types.BuiltinMethodType, types.BuiltinFunctionType): # both the same at the moment but to be future proof - # note: can't get args from these, so dump the string as is - # this means any module used like this must have fully formatted docstrings. - py_c_func2sphinx("", fw, module_name, None, attribute, value, is_class=False) - elif value_type == type: - classes.append((attribute, value)) - elif issubclass(value_type, types.ModuleType): - submodules.append((attribute, value)) - elif value_type in (bool, int, float, str, tuple): - # constant, not much fun we can do here except to list it. - # TODO, figure out some way to document these! - fw(".. data:: %s\n\n" % attribute) - write_indented_lines(" ", fw, "constant value %s" % repr(value), False) - fw("\n") - else: - print("\tnot documenting %s.%s of %r type" % (module_name, attribute, value_type.__name__)) - continue + if attribute.startswith("n_"): # annoying exception, needed for bpy.app + continue + + # workaround for bpy.app documenting .index() and .count() + if isinstance(module, tuple) and hasattr(tuple, attribute): + continue + + value = getattr(module, attribute) + + module_dir_value_type.append((attribute, value, type(value))) + + # sort by str of each type + # this way lists, functions etc are grouped. + module_dir_value_type.sort(key=lambda triple: str(triple[2])) + + for attribute, value, value_type in module_dir_value_type: + if value_type == types.FunctionType: + pyfunc2sphinx("", fw, attribute, value, is_class=False) + elif value_type in (types.BuiltinMethodType, types.BuiltinFunctionType): # both the same at the moment but to be future proof + # note: can't get args from these, so dump the string as is + # this means any module used like this must have fully formatted docstrings. + py_c_func2sphinx("", fw, module_name, None, attribute, value, is_class=False) + elif value_type == type: + classes.append((attribute, value)) + elif issubclass(value_type, types.ModuleType): + submodules.append((attribute, value)) + elif value_type in (bool, int, float, str, tuple): + # constant, not much fun we can do here except to list it. + # TODO, figure out some way to document these! + #fw(".. data:: %s\n\n" % attribute) + write_indented_lines(" ", fw, "constant value %s" % repr(value), False) + fw("\n") + else: + print("\tnot documenting %s.%s of %r type" % (module_name, attribute, value_type.__name__)) + continue - attribute_set.add(attribute) - # TODO, more types... + attribute_set.add(attribute) + # TODO, more types... + del module_dir_value_type # TODO, bpy_extras does this already, mathutils not. """ @@ -1103,6 +1154,8 @@ def rna2sphinx(BASEPATH): fw(" bpy.path.rst\n\n") if "bpy.app" not in EXCLUDE_MODULES: fw(" bpy.app.rst\n\n") + if "bpy.app.handlers" not in EXCLUDE_MODULES: + fw(" bpy.app.handlers.rst\n\n") # C modules if "bpy.props" not in EXCLUDE_MODULES: @@ -1242,6 +1295,10 @@ def rna2sphinx(BASEPATH): from bpy import app as module pymodule2sphinx(BASEPATH, "bpy.app", module, "Application Data") + if "bpy.app.handlers" not in EXCLUDE_MODULES: + from bpy.app import handlers as module + pymodule2sphinx(BASEPATH, "bpy.app.handlers", module, "Application Handlers") + if "bpy.props" not in EXCLUDE_MODULES: from bpy import props as module pymodule2sphinx(BASEPATH, "bpy.props", module, "Property Definitions") diff --git a/intern/audaspace/intern/AUD_C-API.h b/intern/audaspace/intern/AUD_C-API.h index c7b8cb77771..2b7c94bcc5b 100644 --- a/intern/audaspace/intern/AUD_C-API.h +++ b/intern/audaspace/intern/AUD_C-API.h @@ -454,7 +454,7 @@ extern float* AUD_readSoundBuffer(const char* filename, float low, float high, /** * Pauses a playing sound after a specific amount of time. * \param handle The handle to the sound. - * \param time The time in seconds. + * \param seconds The time in seconds. * \return The silence handle. */ extern AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds); diff --git a/intern/ghost/intern/GHOST_Buttons.h b/intern/ghost/intern/GHOST_Buttons.h index 7a3d8b6ae71..0209dc304e4 100644 --- a/intern/ghost/intern/GHOST_Buttons.h +++ b/intern/ghost/intern/GHOST_Buttons.h @@ -52,15 +52,15 @@ struct GHOST_Buttons { /** * Returns the state of a single button. - * @param mask. Key button to return. + * @param mask Key button to return. * @return The state of the button (pressed == true). */ virtual bool get(GHOST_TButtonMask mask) const; /** * Updates the state of a single button. - * @param mask. Button state to update. - * @param down. The new state of the button. + * @param mask Button state to update. + * @param down The new state of the button. */ virtual void set(GHOST_TButtonMask mask, bool down); diff --git a/intern/ghost/intern/GHOST_DisplayManager.h b/intern/ghost/intern/GHOST_DisplayManager.h index 8329d7be94e..d7a9b151d14 100644 --- a/intern/ghost/intern/GHOST_DisplayManager.h +++ b/intern/ghost/intern/GHOST_DisplayManager.h @@ -72,7 +72,7 @@ public: /** * Returns the number of display settings for this display device. * @param display The index of the display to query with 0 <= display < getNumDisplays(). - * @param setting The number of settings of the display device with this index. + * @param numSettings The number of settings of the display device with this index. * @return Indication of success. */ virtual GHOST_TSuccess getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const; diff --git a/intern/ghost/intern/GHOST_EventWheel.h b/intern/ghost/intern/GHOST_EventWheel.h index 0036fa60275..2a82ab8a630 100644 --- a/intern/ghost/intern/GHOST_EventWheel.h +++ b/intern/ghost/intern/GHOST_EventWheel.h @@ -26,7 +26,7 @@ */ /** \file ghost/intern/GHOST_EventWheel.h - * \ingroup GHOSTeel.h + * \ingroup GHOST * Declaration of GHOST_EventWheel class. */ diff --git a/po/POTFILES.in b/po/POTFILES.in deleted file mode 100644 index 5a4ba6a9cb2..00000000000 --- a/po/POTFILES.in +++ /dev/null @@ -1,201 +0,0 @@ -release/scripts/modules/rna_prop_ui.py - -release/scripts/startup/bl_operators/object.py -release/scripts/startup/bl_operators/object_align.py -release/scripts/startup/bl_operators/object_quick_effects.py -release/scripts/startup/bl_operators/object_randomize_transform.py -release/scripts/startup/bl_operators/presets.py -release/scripts/startup/bl_operators/screen_play_rendered_anim.py -release/scripts/startup/bl_operators/sequencer.py -release/scripts/startup/bl_operators/wm.py - -release/scripts/startup/bl_ui/properties_animviz.py -release/scripts/startup/bl_ui/properties_data_armature.py -release/scripts/startup/bl_ui/properties_data_bone.py -release/scripts/startup/bl_ui/properties_data_camera.py -release/scripts/startup/bl_ui/properties_data_curve.py -release/scripts/startup/bl_ui/properties_data_empty.py -release/scripts/startup/bl_ui/properties_data_lamp.py -release/scripts/startup/bl_ui/properties_data_lattice.py -release/scripts/startup/bl_ui/properties_data_mesh.py -release/scripts/startup/bl_ui/properties_data_metaball.py -release/scripts/startup/bl_ui/properties_data_modifier.py -release/scripts/startup/bl_ui/properties_game.py -release/scripts/startup/bl_ui/properties_material.py -release/scripts/startup/bl_ui/properties_object_constraint.py -release/scripts/startup/bl_ui/properties_object.py -release/scripts/startup/bl_ui/properties_particle.py -release/scripts/startup/bl_ui/properties_physics_cloth.py -release/scripts/startup/bl_ui/properties_physics_common.py -release/scripts/startup/bl_ui/properties_physics_field.py -release/scripts/startup/bl_ui/properties_physics_fluid.py -release/scripts/startup/bl_ui/properties_physics_smoke.py -release/scripts/startup/bl_ui/properties_physics_softbody.py -release/scripts/startup/bl_ui/properties_render.py -release/scripts/startup/bl_ui/properties_scene.py -release/scripts/startup/bl_ui/properties_texture.py -release/scripts/startup/bl_ui/properties_world.py - -release/scripts/startup/bl_ui/space_console.py -release/scripts/startup/bl_ui/space_dopesheet.py -release/scripts/startup/bl_ui/space_graph.py -release/scripts/startup/bl_ui/space_image.py -release/scripts/startup/bl_ui/space_info.py -release/scripts/startup/bl_ui/space_logic.py -release/scripts/startup/bl_ui/space_nla.py -release/scripts/startup/bl_ui/space_node.py -release/scripts/startup/bl_ui/space_outliner.py -release/scripts/startup/bl_ui/space_sequencer.py -release/scripts/startup/bl_ui/space_text.py -release/scripts/startup/bl_ui/space_time.py -release/scripts/startup/bl_ui/space_userpref.py -release/scripts/startup/bl_ui/space_userpref_keymap.py -release/scripts/startup/bl_ui/space_view3d.py -release/scripts/startup/bl_ui/space_view3d_toolbar.py - -source/blender/editors/animation/anim_channels_edit.c -source/blender/editors/animation/anim_markers.c -source/blender/editors/animation/anim_ops.c -source/blender/editors/animation/drivers.c -source/blender/editors/animation/keyframing.c -source/blender/editors/animation/keyingsets.c - -source/blender/editors/armature/armature_ops.c -source/blender/editors/armature/editarmature.c -source/blender/editors/armature/editarmature_sketch.c -source/blender/editors/armature/poselib.c -source/blender/editors/armature/poseobject.c -source/blender/editors/armature/poseSlide.c - -source/blender/editors/curve/editcurve.c -source/blender/editors/curve/editfont.c - -source/blender/editors/gpencil/gpencil_paint.c - -source/blender/editors/interface/interface_layout.c -source/blender/editors/interface/interface_ops.c -source/blender/editors/interface/interface_regions.c -source/blender/editors/interface/interface_templates.c -source/blender/editors/interface/interface_utils.c -source/blender/editors/interface/view2d_ops.c - -source/blender/editors/mesh/editmesh.c -source/blender/editors/mesh/editmesh_add.c -source/blender/editors/mesh/editmesh_loop.c -source/blender/editors/mesh/editmesh_mods.c -source/blender/editors/mesh/editmesh_tools.c -source/blender/editors/mesh/loopcut.c -source/blender/editors/mesh/mesh_data.c -source/blender/editors/mesh/mesh_ops.c - -source/blender/editors/metaball/mball_edit.c - -source/blender/editors/object/object_add.c -source/blender/editors/object/object_constraint.c -source/blender/editors/object/object_edit.c -source/blender/editors/object/object_group.c -source/blender/editors/object/object_lattice.c -source/blender/editors/object/object_modifier.c -source/blender/editors/object/object_ops.c -source/blender/editors/object/object_relations.c -source/blender/editors/object/object_select.c -source/blender/editors/object/object_shapekey.c -source/blender/editors/object/object_transform.c -source/blender/editors/object/object_vgroup.c - -source/blender/editors/physics/particle_edit.c -source/blender/editors/physics/particle_object.c -source/blender/editors/physics/physics_pointcache.c - -source/blender/editors/render/render_internal.c -source/blender/editors/render/render_opengl.c -source/blender/editors/render/render_shading.c -source/blender/editors/render/render_view.c - -source/blender/editors/screen/area.c -source/blender/editors/screen/screendump.c -source/blender/editors/screen/screen_ops.c - -source/blender/editors/sculpt_paint/paint_ops.c -source/blender/editors/sculpt_paint/paint_image.c -source/blender/editors/sculpt_paint/paint_utils.c -source/blender/editors/sculpt_paint/paint_vertex.c -source/blender/editors/sculpt_paint/sculpt.c - -source/blender/editors/sound/sound_ops.c - -source/blender/editors/space_action/action_edit.c -source/blender/editors/space_action/action_ops.c -source/blender/editors/space_action/action_select.c - -source/blender/editors/space_buttons/buttons_header.c -source/blender/editors/space_buttons/buttons_ops.c - -source/blender/editors/space_console/console_ops.c - -source/blender/editors/space_file/file_draw.c -source/blender/editors/space_file/file_ops.c -source/blender/editors/space_file/file_panels.c - -source/blender/editors/space_graph/graph_buttons.c -source/blender/editors/space_graph/graph_edit.c -source/blender/editors/space_graph/graph_ops.c -source/blender/editors/space_graph/graph_select.c - -source/blender/editors/space_image/image_buttons.c -source/blender/editors/space_image/image_ops.c - -source/blender/editors/space_info/info_ops.c -source/blender/editors/space_info/info_report.c -source/blender/editors/space_info/space_info.c - -source/blender/editors/space_logic/logic_buttons.c - -source/blender/editors/space_nla/nla_buttons.c -source/blender/editors/space_nla/nla_channels.c -source/blender/editors/space_nla/nla_edit.c -source/blender/editors/space_nla/nla_select.c - -source/blender/editors/space_node/node_buttons.c -source/blender/editors/space_node/node_edit.c -source/blender/editors/space_node/node_header.c -source/blender/editors/space_node/node_ops.c -source/blender/editors/space_node/node_select.c -source/blender/editors/space_node/node_state.c - -source/blender/editors/space_script/script_edit.c - -source/blender/editors/space_sequencer/sequencer_add.c -source/blender/editors/space_sequencer/sequencer_buttons.c -source/blender/editors/space_sequencer/sequencer_edit.c -source/blender/editors/space_sequencer/sequencer_select.c - -source/blender/editors/space_text/text_header.c -source/blender/editors/space_text/text_ops.c -source/blender/editors/space_time/time_ops.c - -source/blender/editors/space_view3d/view3d_buttons.c -source/blender/editors/space_view3d/view3d_draw.c -source/blender/editors/space_view3d/view3d_edit.c -source/blender/editors/space_view3d/view3d_fly.c -source/blender/editors/space_view3d/view3d_header.c -source/blender/editors/space_view3d/view3d_select.c -source/blender/editors/space_view3d/view3d_view.c -source/blender/editors/space_view3d/view3d_toolbar.c - -source/blender/editors/transform/transform.c -source/blender/editors/transform/transform_ops.c -source/blender/editors/transform/transform_orientations.c - -source/blender/editors/util/undo.c - -source/blender/editors/uvedit/uvedit_ops.c -source/blender/editors/uvedit/uvedit_unwrap_ops.c - -source/blender/makesrna/intern/rna_userdef.c - -source/blender/windowmanager/intern/wm_files.c -source/blender/windowmanager/intern/wm_operators.c -source/blender/windowmanager/intern/wm_window.c - - diff --git a/po/README.txt b/po/README.txt deleted file mode 100644 index 6e634ae5ee3..00000000000 --- a/po/README.txt +++ /dev/null @@ -1,81 +0,0 @@ -Blender translation HOWTO -========================= - -I'll try briefly explain how translation works and how to update translation files. - -1. How it works ---------------- - -This folder contains source files for translation system. These source files have -got .po extension and they've got pretty simple syntax: - -msgid "some message id" -msgstr "translation for this message" - -This means when string "some message id" is used as operator name, tooltip, menu -and so it'll be displayed on the screen as "translation for this message". -Pretty simple. - -This source files are pre-compiled into ../release/datafiles/locale/<language>/LC_MESSAGES/blender.mo, -so they aren't getting compiled every time Blender is compiling to save some time and prevent -failure on systems which don't have needed tools for compiling .po files. - -2. How to update translations ------------------------------ - -It's also pretty simple. If you can find string you want to translate in <language>.po -file as msgid, just write correct msgstr string for it. If msgid is marked as fuzzy, -i.e. - -#, fuzzy -msgid "some message id" -msgstr "translation for this message" - -it means translation used to exist for this message, but message was changed, so translation -also have to be updated (it's easier to make new translation based on previous translation). -When translation was updated, remove line with '#, fuzzy' and it'll work. - -If there's no message in .po file you want to translate, probably .po file should be updated. -Use the following steps for this: -- With newly compiled blender run: - `blender --background --factory-startup --python update_msg.py` - to update messages.txt file (this file contains strings collected - automatically from RNA system and python UI scripts) -- Run update_pot.py script which will update blender.pot file. This file contains all - strings which should be transated. -- Run update_po.py script to merge all .po files with blender.pot (so all .po files - will contain all msgid-s declared in blender.pot) or update_po.py <language> to - update only needed .po file(s) to save time when you're busy with translation. - But before commit all .po files better be updated. - -When you've finished with translation, you should re-compile .po file into .mo file. -It's also pretty simple: just run update_mo.py script to recompile all languages or -just update_mo.py <language> to re-compile only needed language(s). - -NOTE: msgfmt, msgmerge and xgettext tools should be available in your PATH. - -These steps to update template, translation files and compile them can be made in "batch" mode -using GNUMakefile: - -make -f GNUMakefile translations - -NOTE: Blender has to be compiled using GNUMakefile first. - - -3. Note for Windows users -------------------------- -You can find compiled builds of gettext in the lib folder under "binaries\gettext\" for both windows and win64. -In order to run the scripts you will need to replace the location of the GETTEXT_..._EXECUTABLE. - -For example in update_pot.py: --GETTEXT_XGETTEXT_EXECUTABLE = "xgettext" -+GETTEXT_XGETTEXT_EXECUTABLE = "C:\\Blender\\lib\\\windows\\\binaries\\\gettext\\xgettext.exe" - -4. Other scripts ----------------- - -- check_po.py: this script checks if all messages declared in blender.pot exists in.po files - and that no extra messages are declared in .po files -- clean_po.py: this script removes all commented messages which aren't required by .pot file anymore. -- merge_po.py: this script accepts two files as arguments and copies translations from second file - into first file. diff --git a/po/check_po.py b/po/check_po.py deleted file mode 100755 index a2b19d57428..00000000000 --- a/po/check_po.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env python - -# ***** 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. -# -# ***** END GPL LICENSE BLOCK ***** - -# <pep8 compliant> - -# update the pot file according the POTFILES.in - -import os -import sys -from codecs import open - -CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) - -FILE_NAME_POT = os.path.join(CURRENT_DIR, "blender.pot") - - -def read_messages(fname): - def stripeol(s): - return s.rstrip("\n\r") - - messages = {} - reading_message = False - message = "" - with open(fname, 'r', "utf-8") as handle: - while True: - line = handle.readline() - - if not line: - break - - line = stripeol(line) - if line.startswith("msgid"): - reading_message = True - message = line[7:-1] - elif line.startswith("msgstr"): - reading_message = False - messages[message] = True - elif reading_message: - message += line[1:-1] - return messages - - -def main(): - pot_messages = read_messages(FILE_NAME_POT) - - if len(sys.argv) > 1: - for lang in sys.argv[1:]: - po = os.path.join(CURRENT_DIR, lang + '.po') - - if os.path.exists(po): - po_messages = read_messages(po) - for msgid in po_messages: - if not pot_messages.get(msgid): - print('Unneeded message id \'%s\'' % (msgid)) - - for msgid in pot_messages: - if not po_messages.get(msgid): - print('Missed message id \'%s\'' % (msgid)) - else: - for po in os.listdir(CURRENT_DIR): - if po.endswith('.po'): - print('Processing %s...' % (po)) - po_messages = read_messages(po) - for msgid in po_messages: - if not pot_messages.get(msgid): - print(' Unneeded message id \'%s\'' % (msgid)) - - for msgid in pot_messages: - if not po_messages.get(msgid): - print(' Missed message id \'%s\'' % (msgid)) - - -if __name__ == "__main__": - print("\n\n *** Running %r *** \n" % __file__) - main() diff --git a/po/clean_po.py b/po/clean_po.py deleted file mode 100755 index 95bac39b42e..00000000000 --- a/po/clean_po.py +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/env python - -# ***** 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. -# -# ***** END GPL LICENSE BLOCK ***** - -# <pep8 compliant> - -# update the pot file according the POTFILES.in - -import os -import sys -import collections - -from codecs import open - -CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) - -FILE_NAME_POT = os.path.join(CURRENT_DIR, "blender.pot") - - -def read_messages(fname): - def stripeol(s): - return s.rstrip("\n\r") - - last_message = None - - if hasattr(collections, 'OrderedDict'): - messages = collections.OrderedDict() - commented_messages = collections.OrderedDict() - else: - messages = {} - commented_messages = {} - - reading_message = False - reading_translation = False - commented = False - message = "" - translation = "" - message_lines = [] - translation_lines = [] - comment_lines = [] - with open(fname, 'r', "utf-8") as handle: - while True: - line = handle.readline() - - if not line: - break - - line = stripeol(line) - if line.startswith("msgid") or line.startswith("#~ msgid"): - if reading_translation: - last_message['translation'] = translation - translation_lines = [] - - reading_message = True - reading_translation = False - - if line.startswith('#~'): - message = line[10:-1] - commented = True - else: - message = line[7:-1] - commented = False - - message_lines.append(message) - elif line.startswith("msgstr") or line.startswith("#~ msgstr"): - reading_message = False - reading_translation = True - last_message = {'comment_lines': comment_lines, - 'message_lines': message_lines, - 'translation_lines': translation_lines} - - if commented: - translation = line[11:-1] - commented_messages[message] = last_message - else: - translation = line[8:-1] - messages[message] = last_message - - message_lines = [] - comment_lines = [] - translation_lines.append(translation) - elif not line.startswith('"') and not line.startswith('#~ "'): - if reading_translation: - last_message['translation'] = translation - else: - comment_lines.append(line) - - reading_message = False - reading_translation = False - message_lines = [] - translation_lines = [] - elif reading_message: - if line.startswith('#~ "'): - m = line[4:-1] - else: - m = line[1:-1] - - message += m - message_lines.append(m) - elif reading_translation: - if line.startswith('#~ "'): - t = line[4:-1] - else: - t = line[1:-1] - - translation += t - translation_lines.append(t) - - return (messages, commented_messages) - - -def do_clean(po, pot_messages): - po_messages, commented_messages = read_messages(po) - - for msgid in commented_messages: - if pot_messages.get(msgid): - t = po_messages.get(msgid) - if not t: - print("Reusing full item from commented " - "lines for msgid '%s'" % msgid) - po_messages[msgid] = commented_messages[msgid] - elif not t['translation']: - print("Reusing translation from commented " - "lines for msgid '%s'" % msgid) - m = commented_messages[msgid] - t['translation'] = m['translation'] - t['translation_lines'] = m['translation_lines'] - - with open(po, 'w', 'utf-8') as handle: - for msgid in po_messages: - item = po_messages[msgid] - - for x in item['comment_lines']: - handle.write(x + "\n") - - first = True - for x in item['message_lines']: - if first: - handle.write("msgid \"%s\"\n" % x) - else: - handle.write("\"%s\"\n" % x) - first = False - - first = True - for x in item['translation_lines']: - if first: - handle.write("msgstr \"%s\"\n" % x) - else: - handle.write("\"%s\"\n" % x) - first = False - - handle.write("\n") - - -def main(): - pot_messages, commented_messages = read_messages(FILE_NAME_POT) - - if len(sys.argv) > 1: - for lang in sys.argv[1:]: - po = os.path.join(CURRENT_DIR, lang + '.po') - - if os.path.exists(po): - do_clean(po, pot_messages) - else: - for po in os.listdir(CURRENT_DIR): - if po.endswith('.po'): - print('Processing %s...' % (po)) - do_clean(po, pot_messages) - - -if __name__ == "__main__": - print("\n\n *** Running %r *** \n" % __file__) - main() diff --git a/po/merge_po.py b/po/merge_po.py deleted file mode 100755 index dcbe9fc9890..00000000000 --- a/po/merge_po.py +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/env python - -# ***** 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. -# -# ***** END GPL LICENSE BLOCK ***** - -# <pep8 compliant> - -# update the pot file according the POTFILES.in - -import sys -import collections - -from codecs import open - - -def read_messages(fname): - def stripeol(s): - return s.rstrip("\n\r") - - last_message = None - - if hasattr(collections, 'OrderedDict'): - messages = collections.OrderedDict() - commented_messages = collections.OrderedDict() - else: - messages = {} - commented_messages = {} - - reading_message = False - reading_translation = False - commented = False - message = "" - translation = "" - message_lines = [] - translation_lines = [] - comment_lines = [] - with open(fname, 'r', "utf-8") as handle: - while True: - line = handle.readline() - - if not line: - break - - line = stripeol(line) - if line.startswith("msgid") or line.startswith("#~ msgid"): - if reading_translation: - last_message['translation'] = translation - translation_lines = [] - - reading_message = True - reading_translation = False - - if line.startswith('#~'): - message = line[10:-1] - commented = True - else: - message = line[7:-1] - commented = False - - message_lines.append(message) - elif line.startswith("msgstr") or line.startswith("#~ msgstr"): - reading_message = False - reading_translation = True - last_message = {'comment_lines': comment_lines, - 'message_lines': message_lines, - 'translation_lines': translation_lines} - - if commented: - translation = line[11:-1] - commented_messages[message] = last_message - else: - translation = line[8:-1] - messages[message] = last_message - - message_lines = [] - comment_lines = [] - translation_lines.append(translation) - elif not line.startswith('"') and not line.startswith('#~ "'): - if reading_translation: - last_message['translation'] = translation - else: - comment_lines.append(line) - - reading_message = False - reading_translation = False - message_lines = [] - translation_lines = [] - elif reading_message: - if line.startswith('#~ "'): - m = line[4:-1] - else: - m = line[1:-1] - - message += m - message_lines.append(m) - elif reading_translation: - if line.startswith('#~ "'): - t = line[4:-1] - else: - t = line[1:-1] - - translation += t - translation_lines.append(t) - - return (messages, commented_messages) - - -def main(): - if len(sys.argv) == 3: - dst_messages, tmp = read_messages(sys.argv[1]) - from_messages, tmp = read_messages(sys.argv[2]) - - for msgid in dst_messages: - msg = dst_messages.get(msgid) - from_msg = from_messages.get(msgid) - - if from_msg and from_msg['translation']: - msg['translation'] = from_msg['translation'] - msg['translation_lines'] = from_msg['translation_lines'] - - with open(sys.argv[1], 'w', 'utf-8') as handle: - for msgid in dst_messages: - item = dst_messages[msgid] - - for x in item['comment_lines']: - handle.write(x + "\n") - - first = True - for x in item['message_lines']: - if first: - handle.write("msgid \"%s\"\n" % x) - else: - handle.write("\"%s\"\n" % x) - first = False - - first = True - for x in item['translation_lines']: - if first: - handle.write("msgstr \"%s\"\n" % x) - else: - handle.write("\"%s\"\n" % x) - first = False - - handle.write("\n") - else: - print('Usage: %s <destination-po> <source-po>' % (sys.argv[0])) - - -if __name__ == "__main__": - print("\n\n *** Running %r *** \n" % __file__) - main() diff --git a/po/update_mo.py b/po/update_mo.py deleted file mode 100755 index 50e99c7eeaa..00000000000 --- a/po/update_mo.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python - -# ***** 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. -# -# ***** END GPL LICENSE BLOCK ***** - -# <pep8 compliant> - -# update all mo files in the LANGS - -import subprocess -import os -import sys - -GETTEXT_MSGFMT_EXECUTABLE = "msgfmt" -CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) -SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.join(CURRENT_DIR, ".."))) -LOCALE_DIR = os.path.join(SOURCE_DIR, "release", "datafiles", "locale") - -DOMAIN = "blender" - - -def process_po(po): - lang = os.path.basename(po)[:-3] - - # show stats - cmd = (GETTEXT_MSGFMT_EXECUTABLE, - "--statistics", - os.path.join(CURRENT_DIR, "%s.po" % lang), - "-o", - os.path.join(LOCALE_DIR, lang, "LC_MESSAGES", "%s.mo" % DOMAIN), - ) - - print(" ".join(cmd)) - process = subprocess.Popen(cmd) - process.wait() - - -def main(): - if len(sys.argv) > 1: - for lang in sys.argv[1:]: - po = os.path.join(CURRENT_DIR, lang + '.po') - - if os.path.exists(po): - process_po(po) - else: - for po in os.listdir(CURRENT_DIR): - if po.endswith(".po"): - process_po(po) - -if __name__ == "__main__": - print("\n\n *** Running %r *** \n" % __file__) - main() diff --git a/po/update_msg.py b/po/update_msg.py deleted file mode 100644 index 21d727922d4..00000000000 --- a/po/update_msg.py +++ /dev/null @@ -1,380 +0,0 @@ -# ***** 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. -# -# ***** END GPL LICENSE BLOCK ***** - -# <pep8-80 compliant> - -# Write out messages.txt from blender - -# Execite: -# blender --background --python po/update_msg.py - -import os - -CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) -SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.join(CURRENT_DIR, ".."))) - -FILE_NAME_MESSAGES = os.path.join(CURRENT_DIR, "messages.txt") -COMMENT_PREFIX = "#~ " - - -def dump_messages_rna(messages): - import bpy - - def classBlackList(): - blacklist_rna_class = [ - # core classes - "Context", "Event", "Function", "UILayout", - "BlendData", - # registerable classes - "Panel", "Menu", "Header", "RenderEngine", - "Operator", "OperatorMacro", "Macro", - "KeyingSetInfo", "UnknownType", - # window classes - "WindowManager", "Window" - ] - - # --------------------------------------------------------------------- - # Collect internal operators - - # extend with all internal operators - # note that this uses internal api introspection functions - # all possible operator names - op_names = list(sorted(set( - [cls.bl_rna.identifier for cls in - bpy.types.OperatorProperties.__subclasses__()] + - [cls.bl_rna.identifier for cls in - bpy.types.Operator.__subclasses__()] + - [cls.bl_rna.identifier for cls in - bpy.types.OperatorMacro.__subclasses__()] - ))) - - get_inatance = __import__("_bpy").ops.get_instance - path_resolve = type(bpy.context).__base__.path_resolve - for idname in op_names: - op = get_inatance(idname) - if 'INTERNAL' in path_resolve(op, "bl_options"): - blacklist_rna_class.append(idname) - - # --------------------------------------------------------------------- - # Collect builtin classes we dont need to doc - blacklist_rna_class.append("Property") - blacklist_rna_class.extend( - [cls.__name__ for cls in - bpy.types.Property.__subclasses__()]) - - # --------------------------------------------------------------------- - # Collect classes which are attached to collections, these are api - # access only. - collection_props = set() - for cls_id in dir(bpy.types): - cls = getattr(bpy.types, cls_id) - for prop in cls.bl_rna.properties: - if prop.type == 'COLLECTION': - prop_cls = prop.srna - if prop_cls is not None: - collection_props.add(prop_cls.identifier) - blacklist_rna_class.extend(sorted(collection_props)) - - return blacklist_rna_class - - blacklist_rna_class = classBlackList() - - def filterRNA(bl_rna): - id = bl_rna.identifier - if id in blacklist_rna_class: - print(" skipping", id) - return True - return False - - # ------------------------------------------------------------------------- - # Function definitions - - def walkProperties(bl_rna): - import bpy - - # get our parents properties not to export them multiple times - bl_rna_base = bl_rna.base - if bl_rna_base: - bl_rna_base_props = bl_rna_base.properties.values() - else: - bl_rna_base_props = () - - for prop in bl_rna.properties: - # only write this property is our parent hasn't got it. - if prop in bl_rna_base_props: - continue - if prop.identifier == "rna_type": - continue - - msgsrc = "bpy.types.%s.%s" % (bl_rna.identifier, prop.identifier) - if prop.name and prop.name != prop.identifier: - messages.setdefault(prop.name, []).append(msgsrc) - if prop.description: - messages.setdefault(prop.description, []).append(msgsrc) - - if isinstance(prop, bpy.types.EnumProperty): - for item in prop.enum_items: - msgsrc = "bpy.types.%s.%s, '%s'" % (bl_rna.identifier, - prop.identifier, - item.identifier, - ) - # Here identifier and name can be the same! - if item.name: # and item.name != item.identifier: - messages.setdefault(item.name, - []).append(msgsrc) - if item.description: - messages.setdefault(item.description, - []).append(msgsrc) - - def walkRNA(bl_rna): - - if filterRNA(bl_rna): - return - - msgsrc = "bpy.types.%s" % bl_rna.identifier - - if bl_rna.name and bl_rna.name != bl_rna.identifier: - messages.setdefault(bl_rna.name, []).append(msgsrc) - - if bl_rna.description: - messages.setdefault(bl_rna.description, []).append(msgsrc) - - if hasattr(bl_rna, 'bl_label') and bl_rna.bl_label: - messages.setdefault(bl_rna.bl_label, []).append(msgsrc) - - walkProperties(bl_rna) - - def walkClass(cls): - walkRNA(cls.bl_rna) - - def walk_keymap_hierarchy(hier, msgsrc_prev): - for lvl in hier: - msgsrc = "%s.%s" % (msgsrc_prev, lvl[1]) - messages.setdefault(lvl[0], []).append(msgsrc) - - if lvl[3]: - walk_keymap_hierarchy(lvl[3], msgsrc) - - # ------------------------------------------------------------------------- - # Dump Messages - - def full_class_id(cls): - """ gives us 'ID.Lamp.AreaLamp' which is best for sorting. - """ - cls_id = "" - bl_rna = cls.bl_rna - while bl_rna: - cls_id = "%s.%s" % (bl_rna.identifier, cls_id) - bl_rna = bl_rna.base - return cls_id - - cls_list = type(bpy.context).__base__.__subclasses__() - cls_list.sort(key=full_class_id) - for cls in cls_list: - walkClass(cls) - - cls_list = bpy.types.Space.__subclasses__() - cls_list.sort(key=full_class_id) - for cls in cls_list: - walkClass(cls) - - cls_list = bpy.types.Operator.__subclasses__() - cls_list.sort(key=full_class_id) - for cls in cls_list: - walkClass(cls) - - cls_list = bpy.types.OperatorProperties.__subclasses__() - cls_list.sort(key=full_class_id) - for cls in cls_list: - walkClass(cls) - - cls_list = bpy.types.Menu.__subclasses__() - cls_list.sort(key=full_class_id) - for cls in cls_list: - walkClass(cls) - - from bpy_extras.keyconfig_utils import KM_HIERARCHY - - walk_keymap_hierarchy(KM_HIERARCHY, "KM_HIERARCHY") - - -def dump_messages_pytext(messages): - """ dumps text inlined in the python user interface: eg. - - layout.prop("someprop", text="My Name") - """ - import ast - - # ------------------------------------------------------------------------- - # Gather function names - - import bpy - # key: func_id - # val: [(arg_kw, arg_pos), (arg_kw, arg_pos), ...] - func_translate_args = {} - - # so far only 'text' keywords, but we may want others translated later - translate_kw = ("text", ) - - for func_id, func in bpy.types.UILayout.bl_rna.functions.items(): - # check it has a 'text' argument - for (arg_pos, (arg_kw, arg)) in enumerate(func.parameters.items()): - if ((arg_kw in translate_kw) and - (arg.is_output == False) and - (arg.type == 'STRING')): - - func_translate_args.setdefault(func_id, []).append((arg_kw, - arg_pos)) - # print(func_translate_args) - - # ------------------------------------------------------------------------- - # Function definitions - - def extract_strings(fp_rel, node_container): - """ Recursively get strings, needed incase we have "Blah" + "Blah", - passed as an argument in that case it wont evaluate to a string. - """ - - for node in ast.walk(node_container): - if type(node) == ast.Str: - eval_str = ast.literal_eval(node) - if eval_str: - # print("%s:%d: %s" % (fp, node.lineno, eval_str)) - msgsrc = "%s:%s" % (fp_rel, node.lineno) - messages.setdefault(eval_str, []).append(msgsrc) - - def extract_strings_from_file(fp): - filedata = open(fp, 'r', encoding="utf8") - root_node = ast.parse(filedata.read(), fp, 'exec') - filedata.close() - - fp_rel = os.path.relpath(fp, SOURCE_DIR) - - for node in ast.walk(root_node): - if type(node) == ast.Call: - # print("found function at") - # print("%s:%d" % (fp, node.lineno)) - - # lambda's - if type(node.func) == ast.Name: - continue - - # getattr(self, con.type)(context, box, con) - if not hasattr(node.func, "attr"): - continue - - translate_args = func_translate_args.get(node.func.attr, ()) - - # do nothing if not found - for arg_kw, arg_pos in translate_args: - if arg_pos < len(node.args): - extract_strings(fp_rel, node.args[arg_pos]) - else: - for kw in node.keywords: - if kw.arg == arg_kw: - extract_strings(fp_rel, kw.value) - - # ------------------------------------------------------------------------- - # Dump Messages - - mod_dir = os.path.join(SOURCE_DIR, - "release", - "scripts", - "startup", - "bl_ui") - - files = [os.path.join(mod_dir, fn) - for fn in sorted(os.listdir(mod_dir)) - if not fn.startswith("_") - if fn.endswith("py") - ] - - for fp in files: - extract_strings_from_file(fp) - - -def dump_messages(): - - def filter_message(msg): - - # check for strings like ": %d" - msg_test = msg - for ignore in ("%d", "%s", "%r", # string formatting - "*", ".", "(", ")", "-", "/", "\\", "+", ":", "#", "%" - "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", - "x", # used on its own eg: 100x200 - "X", "Y", "Z", # used alone. no need to include - ): - msg_test = msg_test.replace(ignore, "") - msg_test = msg_test.strip() - if not msg_test: - # print("Skipping: '%s'" % msg) - return True - - # we could filter out different strings here - - return False - - if 1: - import collections - messages = collections.OrderedDict() - else: - messages = {} - - messages[""] = [] - - # get strings from RNA - dump_messages_rna(messages) - - # get strings from UI layout definitions text="..." args - dump_messages_pytext(messages) - - del messages[""] - - message_file = open(FILE_NAME_MESSAGES, 'w', encoding="utf8") - # message_file.writelines("\n".join(sorted(messages))) - - for key, value in messages.items(): - - # filter out junk values - if filter_message(key): - continue - - for msgsrc in value: - message_file.write("%s%s\n" % (COMMENT_PREFIX, msgsrc)) - message_file.write("%s\n" % key) - - message_file.close() - - print("Written %d messages to: %r" % (len(messages), FILE_NAME_MESSAGES)) - - -def main(): - - try: - import bpy - except ImportError: - print("This script must run from inside blender") - return - - dump_messages() - - -if __name__ == "__main__": - print("\n\n *** Running %r *** \n" % __file__) - main() diff --git a/po/update_po.py b/po/update_po.py deleted file mode 100755 index 0aab8c75646..00000000000 --- a/po/update_po.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python - -# ***** 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. -# -# ***** END GPL LICENSE BLOCK ***** - -# <pep8 compliant> - -# update all po files in the LANGS - -import subprocess -import os -import sys - -GETTEXT_MSGMERGE_EXECUTABLE = "msgmerge" -CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) -DOMAIN = "blender" - - -def process_po(po): - lang = os.path.basename(po)[:-3] - - # update po file - cmd = (GETTEXT_MSGMERGE_EXECUTABLE, - "--update", - "--backup=none", - "--lang=%s" % lang, - os.path.join(CURRENT_DIR, "%s.po" % lang), - os.path.join(CURRENT_DIR, "%s.pot" % DOMAIN), - ) - - print(" ".join(cmd)) - process = subprocess.Popen(cmd) - process.wait() - - -def main(): - if len(sys.argv) > 1: - for lang in sys.argv[1:]: - po = os.path.join(CURRENT_DIR, lang + '.po') - - if os.path.exists(po): - process_po(po) - else: - for po in os.listdir(CURRENT_DIR): - if po.endswith(".po"): - process_po(po) - - -if __name__ == "__main__": - print("\n\n *** Running %r *** \n" % __file__) - main() diff --git a/po/update_pot.py b/po/update_pot.py deleted file mode 100755 index c5f9acb9f42..00000000000 --- a/po/update_pot.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python - -# ***** 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. -# -# ***** END GPL LICENSE BLOCK ***** - -# <pep8 compliant> - -# update the pot file according the POTFILES.in - -import subprocess -import os -from codecs import open - -GETTEXT_XGETTEXT_EXECUTABLE = "xgettext" -CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) -SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.join(CURRENT_DIR, ".."))) -DOMAIN = "blender" -COMMENT_PREFIX = "#~ " # from update_msg.py - -FILE_NAME_POT = os.path.join(CURRENT_DIR, "blender.pot") -FILE_NAME_MESSAGES = os.path.join(CURRENT_DIR, "messages.txt") - - -def main(): - cmd = (GETTEXT_XGETTEXT_EXECUTABLE, - "--files-from=%s" % os.path.join(SOURCE_DIR, "po", "POTFILES.in"), - "--keyword=_", - "--keyword=N_", - "--directory=%s" % SOURCE_DIR, - "--output=%s" % os.path.join(SOURCE_DIR, "po", "%s.pot" % DOMAIN), - "--from-code=utf-8", - ) - - print(" ".join(cmd)) - process = subprocess.Popen(cmd) - process.wait() - - def stripeol(s): - return s.rstrip("\n\r") - - pot_messages = {} - reading_message = False - message = "" - with open(FILE_NAME_POT, 'r', "utf-8") as handle: - while True: - line = handle.readline() - - if not line: - break - - line = stripeol(line) - if line.startswith("msgid"): - reading_message = True - message = line[7:-1] - elif line.startswith("msgstr"): - reading_message = False - pot_messages[message] = True - elif reading_message: - message += line[1:-1] - - # add messages collected automatically from RNA - with open(FILE_NAME_POT, "a", "utf-8") as pot_handle: - with open(FILE_NAME_MESSAGES, 'r', "utf-8") as handle: - msgsrc_ls = [] - while True: - line = handle.readline() - - if not line: - break - - line = stripeol(line) - - # COMMENT_PREFIX - if line.startswith(COMMENT_PREFIX): - msgsrc_ls.append(line[len(COMMENT_PREFIX):].strip()) - else: - line = line.replace("\\", "\\\\") - line = line.replace("\"", "\\\"") - line = line.replace("\t", "\\t") - - if not pot_messages.get(line): - for msgsrc in msgsrc_ls: - pot_handle.write("#: %s\n" % msgsrc) - pot_handle.write("msgid \"%s\"\n" % line) - pot_handle.write("msgstr \"\"\n\n") - msgsrc_ls[:] = [] - - -if __name__ == "__main__": - print("\n\n *** Running %r *** \n" % __file__) - main() diff --git a/release/scripts/presets/camera/APS-C_DSLR.py b/release/scripts/presets/camera/APS-C_DSLR.py new file mode 100644 index 00000000000..829e03cc5cf --- /dev/null +++ b/release/scripts/presets/camera/APS-C_DSLR.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 22.3 +bpy.context.object.data.sensor_height = 14.9 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Blender.py b/release/scripts/presets/camera/Blender.py new file mode 100644 index 00000000000..9fa4ab752e3 --- /dev/null +++ b/release/scripts/presets/camera/Blender.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 32 +bpy.context.object.data.sensor_height = 18 +bpy.context.object.data.sensor_fit = 'AUTO' diff --git a/release/scripts/presets/camera/Canon_1100D.py b/release/scripts/presets/camera/Canon_1100D.py new file mode 100644 index 00000000000..54f2cf75b54 --- /dev/null +++ b/release/scripts/presets/camera/Canon_1100D.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 22.2 +bpy.context.object.data.sensor_height = 14.7 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Canon_1D.py b/release/scripts/presets/camera/Canon_1D.py new file mode 100644 index 00000000000..0bb0e910377 --- /dev/null +++ b/release/scripts/presets/camera/Canon_1D.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 27.9 +bpy.context.object.data.sensor_height = 18.6 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Canon_1DS.py b/release/scripts/presets/camera/Canon_1DS.py new file mode 100644 index 00000000000..158a6235f32 --- /dev/null +++ b/release/scripts/presets/camera/Canon_1DS.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 36.0 +bpy.context.object.data.sensor_height = 24.0 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Canon_500D.py b/release/scripts/presets/camera/Canon_500D.py new file mode 100644 index 00000000000..829e03cc5cf --- /dev/null +++ b/release/scripts/presets/camera/Canon_500D.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 22.3 +bpy.context.object.data.sensor_height = 14.9 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Canon_550D.py b/release/scripts/presets/camera/Canon_550D.py new file mode 100644 index 00000000000..829e03cc5cf --- /dev/null +++ b/release/scripts/presets/camera/Canon_550D.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 22.3 +bpy.context.object.data.sensor_height = 14.9 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Canon_5D.py b/release/scripts/presets/camera/Canon_5D.py new file mode 100644 index 00000000000..158a6235f32 --- /dev/null +++ b/release/scripts/presets/camera/Canon_5D.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 36.0 +bpy.context.object.data.sensor_height = 24.0 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Canon_600D.py b/release/scripts/presets/camera/Canon_600D.py new file mode 100644 index 00000000000..829e03cc5cf --- /dev/null +++ b/release/scripts/presets/camera/Canon_600D.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 22.3 +bpy.context.object.data.sensor_height = 14.9 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Canon_60D.py b/release/scripts/presets/camera/Canon_60D.py new file mode 100644 index 00000000000..829e03cc5cf --- /dev/null +++ b/release/scripts/presets/camera/Canon_60D.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 22.3 +bpy.context.object.data.sensor_height = 14.9 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Canon_7D.py b/release/scripts/presets/camera/Canon_7D.py new file mode 100644 index 00000000000..829e03cc5cf --- /dev/null +++ b/release/scripts/presets/camera/Canon_7D.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 22.3 +bpy.context.object.data.sensor_height = 14.9 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Nikon_D300S.py b/release/scripts/presets/camera/Nikon_D300S.py new file mode 100644 index 00000000000..a0505bf9b9c --- /dev/null +++ b/release/scripts/presets/camera/Nikon_D300S.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 23.6 +bpy.context.object.data.sensor_height = 15.8 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Nikon_D3100.py b/release/scripts/presets/camera/Nikon_D3100.py new file mode 100644 index 00000000000..238d9c22d12 --- /dev/null +++ b/release/scripts/presets/camera/Nikon_D3100.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 23.1 +bpy.context.object.data.sensor_height = 15.4 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Nikon_D35.py b/release/scripts/presets/camera/Nikon_D35.py new file mode 100644 index 00000000000..e6dc62dc100 --- /dev/null +++ b/release/scripts/presets/camera/Nikon_D35.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 36.0 +bpy.context.object.data.sensor_height = 23.9 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Nikon_D5000.py b/release/scripts/presets/camera/Nikon_D5000.py new file mode 100644 index 00000000000..a0505bf9b9c --- /dev/null +++ b/release/scripts/presets/camera/Nikon_D5000.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 23.6 +bpy.context.object.data.sensor_height = 15.8 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Nikon_D5100.py b/release/scripts/presets/camera/Nikon_D5100.py new file mode 100644 index 00000000000..1d819cce65b --- /dev/null +++ b/release/scripts/presets/camera/Nikon_D5100.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 23.6 +bpy.context.object.data.sensor_height = 15.6 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Nikon_D7000.py b/release/scripts/presets/camera/Nikon_D7000.py new file mode 100644 index 00000000000..1d819cce65b --- /dev/null +++ b/release/scripts/presets/camera/Nikon_D7000.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 23.6 +bpy.context.object.data.sensor_height = 15.6 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Nikon_D90.py b/release/scripts/presets/camera/Nikon_D90.py new file mode 100644 index 00000000000..a0505bf9b9c --- /dev/null +++ b/release/scripts/presets/camera/Nikon_D90.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 23.6 +bpy.context.object.data.sensor_height = 15.8 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Red_Epic.py b/release/scripts/presets/camera/Red_Epic.py new file mode 100644 index 00000000000..14f4abaee90 --- /dev/null +++ b/release/scripts/presets/camera/Red_Epic.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 30.0 +bpy.context.object.data.sensor_height = 15.0 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Red_One_2K.py b/release/scripts/presets/camera/Red_One_2K.py new file mode 100644 index 00000000000..ef2708f75b2 --- /dev/null +++ b/release/scripts/presets/camera/Red_One_2K.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 11.1 +bpy.context.object.data.sensor_height = 6.24 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Red_One_3K.py b/release/scripts/presets/camera/Red_One_3K.py new file mode 100644 index 00000000000..5ddff2746eb --- /dev/null +++ b/release/scripts/presets/camera/Red_One_3K.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 16.65 +bpy.context.object.data.sensor_height = 9.36 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/Red_One_4K.py b/release/scripts/presets/camera/Red_One_4K.py new file mode 100644 index 00000000000..8ab9b38cbd5 --- /dev/null +++ b/release/scripts/presets/camera/Red_One_4K.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 22.2 +bpy.context.object.data.sensor_height = 12.6 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/full_frame_35mm_film.py b/release/scripts/presets/camera/full_frame_35mm_film.py new file mode 100644 index 00000000000..d3e141ba4d9 --- /dev/null +++ b/release/scripts/presets/camera/full_frame_35mm_film.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 36 +bpy.context.object.data.sensor_height = 24 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/micro_four_thirds.py b/release/scripts/presets/camera/micro_four_thirds.py new file mode 100644 index 00000000000..36fb0aac391 --- /dev/null +++ b/release/scripts/presets/camera/micro_four_thirds.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 17.3 +bpy.context.object.data.sensor_height = 13.0 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/super_16_film.py b/release/scripts/presets/camera/super_16_film.py new file mode 100644 index 00000000000..1e42953bf05 --- /dev/null +++ b/release/scripts/presets/camera/super_16_film.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 12.52 +bpy.context.object.data.sensor_height = 7.41 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/presets/camera/super_35_film.py b/release/scripts/presets/camera/super_35_film.py new file mode 100644 index 00000000000..65ccb0f216c --- /dev/null +++ b/release/scripts/presets/camera/super_35_film.py @@ -0,0 +1,4 @@ +import bpy +bpy.context.object.data.sensor_width = 24.89 +bpy.context.object.data.sensor_height = 18.66 +bpy.context.object.data.sensor_fit = 'HORIZONTAL' diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 2e42105fbf0..21ac128f177 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -195,6 +195,25 @@ class AddPresetRender(AddPresetBase, Operator): preset_subdir = "render" +class AddPresetCamera(AddPresetBase, Operator): + '''Add a Camera Preset''' + bl_idname = "camera.preset_add" + bl_label = "Add Camera Preset" + preset_menu = "CAMERA_MT_presets" + + preset_defines = [ + "cam = bpy.context.object.data" + ] + + preset_values = [ + "cam.sensor_width", + "cam.sensor_height", + "cam.sensor_fit" + ] + + preset_subdir = "camera" + + class AddPresetSSS(AddPresetBase, Operator): '''Add a Subsurface Scattering Preset''' bl_idname = "material.sss_preset_add" diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index 5255af40951..0abbf281754 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -33,6 +33,14 @@ class CameraButtonsPanel(): return context.camera and (engine in cls.COMPAT_ENGINES) +class CAMERA_MT_presets(bpy.types.Menu): + bl_label = "Camera Presets" + preset_subdir = "camera" + preset_operator = "script.execute_preset" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + draw = bpy.types.Menu.draw_preset + + class DATA_PT_context_camera(CameraButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} @@ -54,7 +62,7 @@ class DATA_PT_context_camera(CameraButtonsPanel, Panel): split.separator() -class DATA_PT_camera(CameraButtonsPanel, Panel): +class DATA_PT_lens(CameraButtonsPanel, Panel): bl_label = "Lens" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -69,12 +77,12 @@ class DATA_PT_camera(CameraButtonsPanel, Panel): col = split.column() if cam.type == 'PERSP': + row = col.row() if cam.lens_unit == 'MILLIMETERS': - col.prop(cam, "lens") + row.prop(cam, "lens") elif cam.lens_unit == 'DEGREES': - col.prop(cam, "angle") - col = split.column() - col.prop(cam, "lens_unit", text="") + row.prop(cam, "angle") + row.prop(cam, "lens_unit", text="") elif cam.type == 'ORTHO': col.prop(cam, "ortho_scale") @@ -100,18 +108,54 @@ class DATA_PT_camera(CameraButtonsPanel, Panel): col.prop(cam, "clip_start", text="Start") col.prop(cam, "clip_end", text="End") - layout.label(text="Depth of Field:") +class DATA_PT_camera(CameraButtonsPanel, Panel): + bl_label = "Camera" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + + def draw(self, context): + layout = self.layout + + cam = context.camera + + row = layout.row(align=True) + + row.menu("CAMERA_MT_presets", text=bpy.types.CAMERA_MT_presets.bl_label) + row.operator("camera.preset_add", text="", icon="ZOOMIN") + row.operator("camera.preset_add", text="", icon="ZOOMOUT").remove_active = True + + layout.label(text="Sensor:") + + split = layout.split() + + col = split.column(align=True) + if cam.sensor_fit == 'AUTO': + col.prop(cam, "sensor_width", text="Size") + else: + col.prop(cam, "sensor_width", text="Width") + col.prop(cam, "sensor_height", text="Height") + + col = split.column(align=True) + col.prop(cam, "sensor_fit", text="") + +class DATA_PT_camera_dof(CameraButtonsPanel, Panel): + bl_label = "Depth of Field" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + + def draw(self, context): + layout = self.layout + + cam = context.camera + + layout.label(text="Focus:") split = layout.split() split.prop(cam, "dof_object", text="") col = split.column() - if cam.dof_object is not None: - col.enabled = False + col.active = cam.dof_object is None col.prop(cam, "dof_distance", text="Distance") - class DATA_PT_camera_display(CameraButtonsPanel, Panel): bl_label = "Display" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -127,10 +171,12 @@ class DATA_PT_camera_display(CameraButtonsPanel, Panel): col.prop(cam, "show_limits", text="Limits") col.prop(cam, "show_mist", text="Mist") col.prop(cam, "show_title_safe", text="Title Safe") + col.prop(cam, "show_sensor", text="Sensor") col.prop(cam, "show_name", text="Name") - col.prop_menu_enum(cam, "show_guide") col = split.column() + col.prop_menu_enum(cam, "show_guide") + col.separator() col.prop(cam, "draw_size", text="Size") col.separator() col.prop(cam, "show_passepartout", text="Passepartout") diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index 0779debb102..a359d58b59e 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -257,10 +257,8 @@ class OBJECT_PT_duplication(ObjectButtonsPanel, Panel): layout.prop(ob, "dupli_group", text="Group") -# XXX: the following options are all quite buggy, ancient hacks that should be dropped - -class OBJECT_PT_animation(ObjectButtonsPanel, Panel): - bl_label = "Animation Hacks" +class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel): + bl_label = "Relations Extras" bl_options = {'DEFAULT_CLOSED'} def draw(self, context): @@ -269,23 +267,17 @@ class OBJECT_PT_animation(ObjectButtonsPanel, Panel): ob = context.object split = layout.split() - - col = split.column() - col.label(text="Time Offset:") - col.prop(ob, "use_time_offset_edit", text="Edit") - row = col.row() - row.prop(ob, "use_time_offset_parent", text="Parent") - row.active = (ob.parent is not None) - row = col.row() - row.prop(ob, "use_slow_parent") - row.active = (ob.parent is not None) - col.prop(ob, "time_offset", text="Offset") - - # XXX: these are still used for a few curve-related tracking features + col = split.column() col.label(text="Tracking Axes:") col.prop(ob, "track_axis", text="Axis") col.prop(ob, "up_axis", text="Up Axis") + + col = split.column() + col.prop(ob, "use_slow_parent") + row = col.row() + row.active = ((ob.parent is not None) and (ob.use_slow_parent)) + row.prop(ob, "slow_parent_offset", text="Offset") from bl_ui.properties_animviz import ( diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 8b69c287048..b626a5dcb55 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2068,7 +2068,22 @@ class VIEW3D_PT_view3d_properties(Panel): subcol.label(text="Local Camera:") subcol.prop(view, "camera", text="") - layout.column().prop(view, "cursor_location") + +class VIEW3D_PT_view3d_cursor(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'UI' + bl_label = "3D Cursor" + + @classmethod + def poll(cls, context): + view = context.space_data + return (view) + + def draw(self, context): + layout = self.layout + + view = context.space_data + layout.column().prop(view, "cursor_location", text="Location") class VIEW3D_PT_view3d_name(Panel): diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 591191321ee..332577a7902 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -172,25 +172,31 @@ class VIEW3D_PT_tools_meshedit(View3DPanel, Panel): class VIEW3D_PT_tools_meshedit_options(View3DPanel, Panel): bl_context = "mesh_edit" bl_label = "Mesh Options" + + @classmethod + def poll(cls, context): + return context.active_object def draw(self, context): layout = self.layout ob = context.active_object - if ob: - mesh = ob.data - col = layout.column(align=True) - col.prop(mesh, "use_mirror_x") - sub = col.column() - sub.active = ob.data.use_mirror_x - sub.prop(mesh, "use_mirror_topology") + tool_settings = context.tool_settings + mesh = ob.data - ts = context.tool_settings + col = layout.column(align=True) + col.active = tool_settings.proportional_edit == 'DISABLED' + col.prop(mesh, "use_mirror_x") - col.label("Edge Select Mode") - col.prop(ts, "edge_path_mode", text="") - col.prop(context.tool_settings, "edge_path_live_unwrap") + row = col.row() + row.active = ob.data.use_mirror_x + row.prop(mesh, "use_mirror_topology") + + col = layout.column(align=True) + col.label("Edge Select Mode:") + col.prop(tool_settings, "edge_path_mode", text="") + col.prop(tool_settings, "edge_path_live_unwrap") # ********** default tools for editmode_curve **************** @@ -1133,7 +1139,7 @@ class VIEW3D_PT_tools_projectpaint(View3DPanel, Panel): sub.prop(ipaint, "normal_angle", text="") split = layout.split() - + split.active = (use_projection) split.prop(ipaint, "use_stencil_layer", text="Stencil") @@ -1148,10 +1154,10 @@ class VIEW3D_PT_tools_projectpaint(View3DPanel, Panel): row.menu("VIEW3D_MT_tools_projectpaint_clone", text=mesh.uv_texture_clone.name) layout.prop(ipaint, "seam_bleed") - + col = layout.column() col.label(text="External Editing:") - + row = col.split(align=True, percentage=0.55) row.operator("image.project_edit", text="Quick Edit") row.operator("image.project_apply", text="Apply") diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index bebc87cc5d4..7ec7e2357dd 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -122,36 +122,37 @@ static void blf_font_ensure_ascii_table(FontBLF *font) /* Note, * blf_font_ensure_ascii_table(font); must be called before this macro */ -#define BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table) \ - if(((c)= (str)[i]) < 0x80) { \ - g= (glyph_ascii_table)[c]; \ - i++; \ +#define BLF_UTF8_NEXT_FAST(_font, _g, _str, _i, _c, _glyph_ascii_table) \ + if(((_c)= (_str)[_i]) < 0x80) { \ + _g= (_glyph_ascii_table)[_c]; \ + _i++; \ } \ - else if ((c= BLI_str_utf8_as_unicode_step((str), &(i))) != BLI_UTF8_ERR) { \ - if ((g= blf_glyph_search((font)->glyph_cache, c)) == NULL) { \ - g= blf_glyph_add(font, FT_Get_Char_Index((font)->face, c), c); \ + else if ((_c= BLI_str_utf8_as_unicode_step(_str, &(_i)))!=BLI_UTF8_ERR) { \ + if ((_g= blf_glyph_search((_font)->glyph_cache, _c)) == NULL) { \ + _g= blf_glyph_add(_font, \ + FT_Get_Char_Index((_font)->face, _c), _c); \ } \ } \ #define BLF_KERNING_VARS(_font, _has_kerning, _kern_mode) \ - const short has_kerning= FT_HAS_KERNING((_font)->face); \ - const FT_UInt kern_mode= (has_kerning == 0) ? 0 : \ + const short _has_kerning= FT_HAS_KERNING((_font)->face); \ + const FT_UInt _kern_mode= (_has_kerning == 0) ? 0 : \ (((_font)->flags & BLF_KERNING_DEFAULT) ? \ ft_kerning_default : FT_KERNING_UNFITTED) \ -#define BLF_KERNING_STEP(_font, kern_mode, g_prev, g, delta, pen_x) \ +#define BLF_KERNING_STEP(_font, _kern_mode, _g_prev, _g, _delta, _pen_x) \ { \ - if (g_prev) { \ - delta.x= delta.y= 0; \ + if (_g_prev) { \ + _delta.x= _delta.y= 0; \ if (FT_Get_Kerning((_font)->face, \ - (g_prev)->idx, \ - (g)->idx, \ - kern_mode, \ - &(delta)) == 0) \ + (_g_prev)->idx, \ + (_g)->idx, \ + _kern_mode, \ + &(_delta)) == 0) \ { \ - pen_x += delta.x >> 6; \ + _pen_x += delta.x >> 6; \ } \ } \ } \ diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index cba6b0ef257..8e5b313b919 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -105,10 +105,10 @@ void BKE_keyingsets_free(struct ListBase *list); /* Path Fixing API */ /* Fix all the paths for the given ID+AnimData */ -void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, const char *prefix, char *oldName, char *newName, int oldSubscript, int newSubscript, int verify_paths); +void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, int verify_paths); /* Fix all the paths for the entire database... */ -void BKE_all_animdata_fix_paths_rename(char *prefix, char *oldName, char *newName); +void BKE_all_animdata_fix_paths_rename(const char *prefix, const char *oldName, const char *newName); /* -------------------------------------- */ diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index a6b98749eda..db576b2de88 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 260 -#define BLENDER_SUBVERSION 0 +#define BLENDER_SUBVERSION 1 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 @@ -87,7 +87,7 @@ extern int BKE_undo_valid(const char *name); extern void BKE_reset_undo(void); extern char *BKE_undo_menu_string(void); extern void BKE_undo_number(struct bContext *C, int nr); -extern char *BKE_undo_get_name(int nr, int *active); +extern const char *BKE_undo_get_name(int nr, int *active); void BKE_undo_save(char *fname); extern void BKE_undo_save_quit(void); extern struct Main *BKE_undo_get_main(struct Scene **scene); diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h new file mode 100644 index 00000000000..d21c1092922 --- /dev/null +++ b/source/blender/blenkernel/BKE_camera.h @@ -0,0 +1,71 @@ +/* + * ***** 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) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BKE_CAMERA_H +#define BKE_CAMERA_H + +/** \file BKE_camera.h + * \ingroup bke + * \brief Camera datablock and utility functions. + */ +#ifdef __cplusplus +extern "C" { +#endif + +struct Camera; +struct Object; +struct RenderData; +struct Scene; +struct rctf; + +void *add_camera(const char *name); +struct Camera *copy_camera(struct Camera *cam); +void make_local_camera(struct Camera *cam); +void free_camera(struct Camera *ca); + +float dof_camera(struct Object *ob); + +void object_camera_mode(struct RenderData *rd, struct Object *camera); +void object_camera_intrinsics(struct Object *camera, struct Camera **cam_r, short *is_ortho, float *shiftx, float *shifty, + float *clipsta, float *clipend, float *lens, float *sensor_x, float *sensor_y, short *sensor_fit); +void object_camera_matrix( + struct RenderData *rd, struct Object *camera, int winx, int winy, short field_second, + float winmat[][4], struct rctf *viewplane, float *clipsta, float *clipend, float *lens, + float *sensor_x, float *sensor_y, short *sensor_fit, float *ycor, + float *viewdx, float *viewdy); + +void camera_view_frame_ex(struct Scene *scene, struct Camera *camera, float drawsize, const short do_clip, const float scale[3], + float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]); + +void camera_view_frame(struct Scene *scene, struct Camera *camera, float r_vec[4][3]); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 3f9edf41e3c..c065a210a98 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -203,17 +203,17 @@ int CTX_data_dir(const char *member); /*void CTX_data_pointer_set(bContextDataResult *result, void *data); void CTX_data_list_add(bContextDataResult *result, void *data);*/ -#define CTX_DATA_BEGIN(C, Type, instance, member) \ - { \ - ListBase ctx_data_list; \ - CollectionPointerLink *ctx_link; \ - CTX_data_##member(C, &ctx_data_list); \ - for(ctx_link=ctx_data_list.first; ctx_link; ctx_link=ctx_link->next) { \ +#define CTX_DATA_BEGIN(C, Type, instance, member) \ + { \ + ListBase ctx_data_list; \ + CollectionPointerLink *ctx_link; \ + CTX_data_##member(C, &ctx_data_list); \ + for(ctx_link=ctx_data_list.first; ctx_link; ctx_link=ctx_link->next) {\ Type instance= ctx_link->ptr.data; -#define CTX_DATA_END \ - } \ - BLI_freelistN(&ctx_data_list); \ +#define CTX_DATA_END \ + } \ + BLI_freelistN(&ctx_data_list); \ } int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase*)); diff --git a/source/blender/blenkernel/BKE_customdata_file.h b/source/blender/blenkernel/BKE_customdata_file.h index f32a4b1e6a8..be7aaa70188 100644 --- a/source/blender/blenkernel/BKE_customdata_file.h +++ b/source/blender/blenkernel/BKE_customdata_file.h @@ -40,22 +40,22 @@ void cdf_free(CDataFile *cdf); /* File read/write/remove */ -int cdf_read_open(CDataFile *cdf, char *filename); +int cdf_read_open(CDataFile *cdf, const char *filename); int cdf_read_layer(CDataFile *cdf, CDataFileLayer *blay); int cdf_read_data(CDataFile *cdf, unsigned int size, void *data); void cdf_read_close(CDataFile *cdf); -int cdf_write_open(CDataFile *cdf, char *filename); +int cdf_write_open(CDataFile *cdf, const char *filename); int cdf_write_layer(CDataFile *cdf, CDataFileLayer *blay); int cdf_write_data(CDataFile *cdf, unsigned int size, void *data); void cdf_write_close(CDataFile *cdf); -void cdf_remove(char *filename); +void cdf_remove(const char *filename); /* Layers */ -CDataFileLayer *cdf_layer_find(CDataFile *cdf, int type, char *name); -CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, char *name, size_t datasize); +CDataFileLayer *cdf_layer_find(CDataFile *cdf, int type, const char *name); +CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t datasize); #endif /* BKE_CUSTOMDATA_FILE_H */ diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index 0b0637fb42a..e0b8e40d731 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -133,6 +133,9 @@ void DAG_pose_sort(struct Object *ob); /* callback for editors module to do updates */ void DAG_editors_update_cb(void (*func)(struct Main *bmain, struct ID *id)); + /* debugging */ +void DAG_print_dependencies(struct Main *bmain, struct Scene *scene, struct Object *ob); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_lamp.h b/source/blender/blenkernel/BKE_lamp.h new file mode 100644 index 00000000000..cc9452ae155 --- /dev/null +++ b/source/blender/blenkernel/BKE_lamp.h @@ -0,0 +1,51 @@ +/* + * ***** 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) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BKE_LAMP_H +#define BKE_LAMP_H + +/** \file BKE_lamp.h + * \ingroup bke + * \brief General operations, lookup, etc. for blender lamps. + */ +#ifdef __cplusplus +extern "C" { +#endif + +struct Lamp; + +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_lamp(struct Lamp *la); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index 57c05637d50..dcca857179c 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -55,19 +55,19 @@ void end_latt_deform(struct Object *); int object_deform_mball(struct Object *ob, struct ListBase *dispbase); void outside_lattice(struct Lattice *lt); -void curve_deform_verts(struct Scene *scene, struct Object *cuOb, struct Object *target, - struct DerivedMesh *dm, float (*vertexCos)[3], - int numVerts, char *vgroup, short defaxis); -void curve_deform_vector(struct Scene *scene, struct Object *cuOb, struct Object *target, - float *orco, float *vec, float mat[][3], int no_rot_axis); +void curve_deform_verts(struct Scene *scene, struct Object *cuOb, struct Object *target, + struct DerivedMesh *dm, float (*vertexCos)[3], + int numVerts, const char *vgroup, short defaxis); +void curve_deform_vector(struct Scene *scene, struct Object *cuOb, struct Object *target, + float *orco, float *vec, float mat[][3], int no_rot_axis); void lattice_deform_verts(struct Object *laOb, struct Object *target, - struct DerivedMesh *dm, float (*vertexCos)[3], - int numVerts, char *vgroup); + struct DerivedMesh *dm, float (*vertexCos)[3], + int numVerts, const char *vgroup); void armature_deform_verts(struct Object *armOb, struct Object *target, - struct DerivedMesh *dm, float (*vertexCos)[3], - float (*defMats)[3][3], int numVerts, int deformflag, - float (*prevCos)[3], const char *defgrp_name); + struct DerivedMesh *dm, float (*vertexCos)[3], + float (*defMats)[3][3], int numVerts, int deformflag, + float (*prevCos)[3], const char *defgrp_name); float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3]; void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3]); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 393568c6b60..85a986d3460 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -74,18 +74,7 @@ void object_copy_proxy_drivers(struct Object *ob, struct Object *target); void unlink_object(struct Object *ob); int exist_object(struct Object *obtest); -void *add_camera(const char *name); -struct Camera *copy_camera(struct Camera *cam); -void make_local_camera(struct Camera *cam); -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); - struct Object *add_only_object(int type, const char *name); struct Object *add_object(struct Scene *scene, int type); @@ -97,7 +86,6 @@ void set_mblur_offs(float blur); void set_field_offs(float field); void disable_speed_curve(int val); -float bsystem_time(struct Scene *scene, struct Object *ob, float cfra, float ofs); void object_scale_to_mat3(struct Object *ob, float mat[][3]); void object_rot_to_mat3(struct Object *ob, float mat[][3]); void object_mat3_to_rot(struct Object *ob, float mat[][3], short use_compat); @@ -129,7 +117,6 @@ void object_tfm_restore(struct Object *ob, void *obtfm_pt); void object_handle_update(struct Scene *scene, struct Object *ob); void object_sculpt_modifiers_changed(struct Object *ob); -float give_timeoffset(struct Object *ob); int give_obdata_texspace(struct Object *ob, short **texflag, float **loc, float **size, float **rot); int object_insert_ptcache(struct Object *ob); @@ -138,17 +125,6 @@ struct KeyBlock *object_insert_shape_key(struct Scene *scene, struct Object *ob, int object_is_modified(struct Scene *scene, struct Object *ob); -void object_camera_mode(struct RenderData *rd, struct Object *camera); -void object_camera_matrix( - struct RenderData *rd, struct Object *camera, int winx, int winy, short field_second, - float winmat[][4], struct rctf *viewplane, float *clipsta, float *clipend, float *lens, float *ycor, - float *viewdx, float *viewdy); - -void camera_view_frame_ex(struct Scene *scene, struct Camera *camera, float drawsize, const short do_clip, const float scale[3], - float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]); - -void camera_view_frame(struct Scene *scene, struct Camera *camera, float r_vec[4][3]); - void object_relink(struct Object *ob); #ifdef __cplusplus diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 110e6e851c8..28ca1006a03 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -323,7 +323,7 @@ void BKE_ptcache_mem_to_disk(struct PTCacheID *pid); void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid); /* Rename all disk cache files with a new name. Doesn't touch the actual content of the files. */ -void BKE_ptcache_disk_cache_rename(struct PTCacheID *pid, char *from, char *to); +void BKE_ptcache_disk_cache_rename(struct PTCacheID *pid, const char *name_src, const char *name_dst); /* Loads simulation from external (disk) cache files. */ void BKE_ptcache_load_external(struct PTCacheID *pid); diff --git a/source/blender/blenkernel/BKE_property.h b/source/blender/blenkernel/BKE_property.h index ce0ea3dcc9a..779c83acf21 100644 --- a/source/blender/blenkernel/BKE_property.h +++ b/source/blender/blenkernel/BKE_property.h @@ -44,11 +44,10 @@ struct bProperty *new_property(int type); void unique_property(struct bProperty *first, struct bProperty *prop, int force); struct bProperty *get_ob_property(struct Object *ob, const char *name); void set_ob_property(struct Object *ob, struct bProperty *propc); -int compare_property(struct bProperty *prop, char *str); -void set_property(struct bProperty *prop, char *str); -void add_property(struct bProperty *prop, char *str); +int compare_property(struct bProperty *prop, const char *str); +void set_property(struct bProperty *prop, const char *str); +void add_property(struct bProperty *prop, const char *str); void set_property_valstr(struct bProperty *prop, char *str); void cp_property(struct bProperty *prop1, struct bProperty *prop2); #endif - diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 4806a288cee..a6bd90c4fd2 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -86,6 +86,7 @@ void scene_select_base(struct Scene *sce, struct Base *selbase); int scene_check_setscene(struct Main *bmain, struct Scene *sce); float BKE_curframe(struct Scene *scene); +float BKE_nextframe(struct Scene *scene); void scene_update_tagged(struct Main *bmain, struct Scene *sce); void scene_clear_tagged(struct Main *bmain, struct Scene *sce); diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 5b6d7e3cd96..77a351d534e 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -34,22 +34,23 @@ */ struct ARegion; -struct bContext; -struct bContextDataResult; -struct bScreen; -struct ListBase; -struct Panel; struct Header; +struct ListBase; struct Menu; +struct Panel; +struct Scene; struct ScrArea; struct SpaceType; -struct Scene; +struct View3D; +struct bContext; +struct bContextDataResult; +struct bScreen; +struct uiLayout; +struct uiMenuItem; +struct wmKeyConfig; struct wmNotifier; struct wmWindow; struct wmWindowManager; -struct wmKeyConfig; -struct uiLayout; -struct uiMenuItem; #include "RNA_types.h" @@ -239,6 +240,7 @@ void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar); void BKE_screen_area_free(struct ScrArea *sa); struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type); +struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min); void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene); void BKE_screen_view3d_scene_sync(struct bScreen *sc); diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index e64de965db5..a16e55ce8ff 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -67,21 +67,21 @@ void seq_next(SeqIterator *iter); void seq_end(SeqIterator *iter); void seq_array(struct Editing *ed, struct Sequence ***seqarray, int *tot, int use_pointer); -#define SEQP_BEGIN(ed, _seq) \ -{ \ - SeqIterator iter;\ - for(seq_begin(ed, &iter, 1); iter.valid; seq_next(&iter)) { \ +#define SEQP_BEGIN(ed, _seq) \ +{ \ + SeqIterator iter; \ + for(seq_begin(ed, &iter, 1); iter.valid; seq_next(&iter)) { \ _seq= iter.seq; -#define SEQ_BEGIN(ed, _seq) \ - { \ - SeqIterator iter;\ - for(seq_begin(ed, &iter, 0); iter.valid; seq_next(&iter)) { \ +#define SEQ_BEGIN(ed, _seq) \ + { \ + SeqIterator iter; \ + for(seq_begin(ed, &iter, 0); iter.valid; seq_next(&iter)) { \ _seq= iter.seq; -#define SEQ_END \ - } \ - seq_end(&iter); \ +#define SEQ_END \ + } \ + seq_end(&iter); \ } typedef struct SeqRenderData { @@ -274,7 +274,7 @@ struct Sequence *seq_metastrip( struct Sequence * meta /* = NULL */, struct Sequence *seq); void seq_offset_animdata(struct Scene *scene, struct Sequence *seq, int ofs); -void seq_dupe_animdata(struct Scene *scene, char *name_from, char *name_to); +void seq_dupe_animdata(struct Scene *scene, const char *name_src, const char *name_dst); int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test, struct Scene *evil_scene); int shuffle_seq_time(ListBase * seqbasep, struct Scene *evil_scene); int seqbase_isolated_sel_check(struct ListBase *seqbase); diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 2a613522686..a951347d946 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -56,7 +56,7 @@ void write_text(struct Text *text, const char *str); char* txt_to_buf (struct Text *text); void txt_clean_text (struct Text *text); void txt_order_cursors (struct Text *text); -int txt_find_string (struct Text *text, char *findstr, int wrap, int match_case); +int txt_find_string (struct Text *text, const char *findstr, int wrap, int match_case); int txt_has_sel (struct Text *text); int txt_get_span (struct TextLine *from, struct TextLine *to); void txt_move_up (struct Text *text, short sel); diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h index 1f54e4eeef0..db586f6d262 100644 --- a/source/blender/blenkernel/BKE_unit.h +++ b/source/blender/blenkernel/BKE_unit.h @@ -37,10 +37,10 @@ extern "C" { void bUnit_AsString(char *str, int len_max, double value, int prec, int system, int type, int split, int pad); /* replace units with values, used before python button evaluation */ -int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pref, int system, int type); +int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double scale_pref, int system, int type); /* make string keyboard-friendly: 10µm --> 10um */ -void bUnit_ToUnitAltName(char *str, int len_max, char *orig_str, int system, int type); +void bUnit_ToUnitAltName(char *str, int len_max, const char *orig_str, int system, int type); /* the size of the unit used for this value (used for calculating the ckickstep) */ double bUnit_ClosestScalar(double value, int system, int type); diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index 2b10f1b246c..3263a1659f3 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -74,7 +74,7 @@ void filepath_ffmpeg(char* string, struct RenderData* rd); extern void ffmpeg_set_preset(struct RenderData *rd, int preset); extern void ffmpeg_verify_image_type(struct RenderData *rd); -extern struct IDProperty *ffmpeg_property_add(struct RenderData *Rd, char *type, int opt_index, int parent_index); +extern struct IDProperty *ffmpeg_property_add(struct RenderData *Rd, const char *type, int opt_index, int parent_index); extern int ffmpeg_property_add_string(struct RenderData *rd, const char *type, const char *str); extern void ffmpeg_property_del(struct RenderData *rd, void *type, void *prop_); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 568c5f489fa..82a179eac4a 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -77,6 +77,7 @@ set(SRC intern/brush.c intern/bullet.c intern/bvhutils.c + intern/camera.c intern/cdderivedmesh.c intern/cloth.c intern/collision.c @@ -105,6 +106,7 @@ set(SRC intern/implicit.c intern/ipo.c intern/key.c + intern/lamp.c intern/lattice.c intern/library.c intern/material.c @@ -163,6 +165,7 @@ set(SRC BKE_brush.h BKE_bullet.h BKE_bvhutils.h + BKE_camera.h BKE_cdderivedmesh.h BKE_cloth.h BKE_collision.h @@ -188,6 +191,7 @@ set(SRC BKE_image.h BKE_ipo.h BKE_key.h + BKE_lamp.h BKE_lattice.h BKE_library.h BKE_main.h diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index accc111aacc..224f25db2f7 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -754,6 +754,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, extern int enable_cu_speed; /* object.c */ Object copyob = {{NULL}}; int cfrao = scene->r.cfra; + int dupend = ob->dupend; /* simple prevention of too deep nested groups */ if (level > MAX_DUPLI_RECUR) return; @@ -774,7 +775,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, /* duplicate over the required range */ if (ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0; - for (scene->r.cfra= ob->dupsta; scene->r.cfra<=ob->dupend; scene->r.cfra++) { + for (scene->r.cfra= ob->dupsta; scene->r.cfra<=dupend; scene->r.cfra++) { short ok= 1; /* - dupoff = how often a frames within the range shouldn't be made into duplis @@ -1226,7 +1227,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if(G.rendering == 0) no_draw_flag |= PARS_NO_DISP; - ctime = bsystem_time(scene, par, (float)scene->r.cfra, 0.0); + ctime = BKE_curframe(scene); /* NOTE: in old animsys, used parent object's timeoffset... */ totpart = psys->totpart; totchild = psys->totchild; diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 6d94b42a7ac..63ab74fc105 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -545,7 +545,7 @@ void BKE_animdata_separate_by_basepath (ID *srcID, ID *dstID, ListBase *basepath /* Path Validation -------------------------------------------- */ /* Check if a given RNA Path is valid, by tracing it from the given ID, and seeing if we can resolve it */ -static short check_rna_path_is_valid (ID *owner_id, char *path) +static short check_rna_path_is_valid (ID *owner_id, const char *path) { PointerRNA id_ptr, ptr; PropertyRNA *prop=NULL; @@ -560,7 +560,7 @@ static short check_rna_path_is_valid (ID *owner_id, char *path) /* Check if some given RNA Path needs fixing - free the given path and set a new one as appropriate * NOTE: we assume that oldName and newName have [" "] padding around them */ -static char *rna_path_rename_fix (ID *owner_id, const char *prefix, char *oldName, char *newName, char *oldpath, int verify_paths) +static char *rna_path_rename_fix (ID *owner_id, const char *prefix, const char *oldName, const char *newName, char *oldpath, int verify_paths) { char *prefixPtr= strstr(oldpath, prefix); char *oldNamePtr= strstr(oldpath, oldName); @@ -631,7 +631,7 @@ static void fcurves_path_rename_fix (ID *owner_id, const char *prefix, char *old } /* Check RNA-Paths for a list of Drivers */ -static void drivers_path_rename_fix (ID *owner_id, const char *prefix, char *oldName, char *newName, char *oldKey, char *newKey, ListBase *curves, int verify_paths) +static void drivers_path_rename_fix (ID *owner_id, const char *prefix, const char *oldName, const char *newName, const char *oldKey, const char *newKey, ListBase *curves, int verify_paths) { FCurve *fcu; @@ -691,7 +691,7 @@ static void nlastrips_path_rename_fix (ID *owner_id, const char *prefix, char *o * NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]> * i.e. pose.bones["Bone"] */ -void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, const char *prefix, char *oldName, char *newName, int oldSubscript, int newSubscript, int verify_paths) +void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, int verify_paths) { NlaTrack *nlt; char *oldN, *newN; @@ -808,7 +808,7 @@ void BKE_animdata_main_cb (Main *mainptr, ID_AnimData_Edit_Callback func, void * * i.e. pose.bones["Bone"] */ /* TODO: use BKE_animdata_main_cb for looping over all data */ -void BKE_all_animdata_fix_paths_rename (char *prefix, char *oldName, char *newName) +void BKE_all_animdata_fix_paths_rename (const char *prefix, const char *oldName, const char *newName) { Main *mainptr= G.main; ID *id; diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index e9a19b50a81..f19ed859064 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -68,6 +68,7 @@ #include "BKE_lattice.h" #include "BKE_main.h" #include "BKE_object.h" +#include "BKE_scene.h" #include "BIK_api.h" #include "BKE_sketch.h" @@ -2406,7 +2407,7 @@ void where_is_pose (Scene *scene, Object *ob) if((ob->pose==NULL) || (ob->pose->flag & POSE_RECALC)) armature_rebuild_pose(ob, arm); - ctime= bsystem_time(scene, ob, (float)scene->r.cfra, 0.0); /* not accurate... */ + ctime= BKE_curframe(scene); /* not accurate... */ /* In editmode or restposition we read the data from the bones */ if(arm->edbo || (arm->flag & ARM_RESTPOS)) { diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 3847770eefc..af31da7af1e 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -664,7 +664,7 @@ int BKE_undo_valid(const char *name) /* get name of undo item, return null if no item with this index */ /* if active pointer, set it to 1 if true */ -char *BKE_undo_get_name(int nr, int *active) +const char *BKE_undo_get_name(int nr, int *active) { UndoElem *uel= BLI_findlink(&undobase, nr); diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c new file mode 100644 index 00000000000..eeec82c3beb --- /dev/null +++ b/source/blender/blenkernel/intern/camera.c @@ -0,0 +1,396 @@ +/* + * ***** 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) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/camera.c + * \ingroup bke + */ + +#include <stdlib.h> + +#include "DNA_camera_types.h" +#include "DNA_lamp_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BKE_animsys.h" +#include "BKE_camera.h" +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_main.h" + +void *add_camera(const char *name) +{ + Camera *cam; + + cam= alloc_libblock(&G.main->camera, ID_CA, name); + + cam->lens= 35.0f; + cam->sensor_x= 32.0f; + cam->sensor_y= 18.0f; + cam->clipsta= 0.1f; + cam->clipend= 100.0f; + cam->drawsize= 0.5f; + cam->ortho_scale= 6.0; + cam->flag |= CAM_SHOWPASSEPARTOUT; + cam->passepartalpha = 0.5f; + + return cam; +} + +Camera *copy_camera(Camera *cam) +{ + Camera *camn; + + camn= copy_libblock(cam); + + return camn; +} + +void make_local_camera(Camera *cam) +{ + Main *bmain= G.main; + Object *ob; + int is_local= FALSE, is_lib= FALSE; + + /* - only lib users: do nothing + * - only local users: set flag + * - mixed: make copy + */ + + if(cam->id.lib==NULL) return; + if(cam->id.us==1) { + id_clear_lib_data(bmain, &cam->id); + return; + } + + for(ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) { + if(ob->data==cam) { + if(ob->id.lib) is_lib= TRUE; + else is_local= TRUE; + } + } + + if(is_local && is_lib == FALSE) { + id_clear_lib_data(bmain, &cam->id); + } + else if(is_local && is_lib) { + Camera *camn= copy_camera(cam); + + camn->id.us= 0; + + /* Remap paths of new ID using old library as base. */ + BKE_id_lib_local_paths(bmain, &camn->id); + + for(ob= bmain->object.first; ob; ob= ob->id.next) { + if(ob->data == cam) { + if(ob->id.lib==NULL) { + ob->data= camn; + camn->id.us++; + cam->id.us--; + } + } + } + } +} + +/* get the camera's dof value, takes the dof object into account */ +float dof_camera(Object *ob) +{ + Camera *cam = (Camera *)ob->data; + if (ob->type != OB_CAMERA) + return 0.0f; + if (cam->dof_ob) { + /* too simple, better to return the distance on the view axis only + * return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */ + float mat[4][4], imat[4][4], obmat[4][4]; + + copy_m4_m4(obmat, ob->obmat); + normalize_m4(obmat); + invert_m4_m4(imat, obmat); + mul_m4_m4m4(mat, cam->dof_ob->obmat, imat); + return (float)fabs(mat[3][2]); + } + return cam->YF_dofdist; +} + +void free_camera(Camera *ca) +{ + BKE_free_animdata((ID *)ca); +} + +void object_camera_mode(RenderData *rd, Object *camera) +{ + rd->mode &= ~(R_ORTHO|R_PANORAMA); + if(camera && camera->type==OB_CAMERA) { + Camera *cam= camera->data; + if(cam->type == CAM_ORTHO) rd->mode |= R_ORTHO; + if(cam->flag & CAM_PANORAMA) rd->mode |= R_PANORAMA; + } +} + +void object_camera_intrinsics(Object *camera, Camera **cam_r, short *is_ortho, float *shiftx, float *shifty, + float *clipsta, float *clipend, float *lens, float *sensor_x, float *sensor_y, short *sensor_fit) +{ + Camera *cam= NULL; + + (*shiftx)= 0.0f; + (*shifty)= 0.0f; + + (*sensor_x)= DEFAULT_SENSOR_WIDTH; + (*sensor_y)= DEFAULT_SENSOR_HEIGHT; + (*sensor_fit)= CAMERA_SENSOR_FIT_AUTO; + + if(camera->type==OB_CAMERA) { + cam= camera->data; + + if(cam->type == CAM_ORTHO) { + *is_ortho= TRUE; + } + + /* solve this too... all time depending stuff is in convertblender.c? + * Need to update the camera early because it's used for projection matrices + * and other stuff BEFORE the animation update loop is done + * */ +#if 0 // XXX old animation system + if(cam->ipo) { + calc_ipo(cam->ipo, frame_to_float(re->scene, re->r.cfra)); + execute_ipo(&cam->id, cam->ipo); + } +#endif // XXX old animation system + (*shiftx)=cam->shiftx; + (*shifty)=cam->shifty; + (*lens)= cam->lens; + (*sensor_x)= cam->sensor_x; + (*sensor_y)= cam->sensor_y; + (*clipsta)= cam->clipsta; + (*clipend)= cam->clipend; + (*sensor_fit)= cam->sensor_fit; + } + else if(camera->type==OB_LAMP) { + Lamp *la= camera->data; + float fac= cosf((float)M_PI*la->spotsize/360.0f); + float phi= acos(fac); + + (*lens)= 16.0f*fac/sinf(phi); + if((*lens)==0.0f) + (*lens)= 35.0f; + (*clipsta)= la->clipsta; + (*clipend)= la->clipend; + } + else { /* envmap exception... */; + if((*lens)==0.0f) /* is this needed anymore? */ + (*lens)= 16.0f; + + if((*clipsta)==0.0f || (*clipend)==0.0f) { + (*clipsta)= 0.1f; + (*clipend)= 1000.0f; + } + } + + (*cam_r)= cam; +} + +/* 'lens' may be set for envmap only */ +void object_camera_matrix( + RenderData *rd, Object *camera, int winx, int winy, short field_second, + float winmat[][4], rctf *viewplane, float *clipsta, float *clipend, float *lens, + float *sensor_x, float *sensor_y, short *sensor_fit, float *ycor, + float *viewdx, float *viewdy) +{ + Camera *cam=NULL; + float pixsize; + float shiftx=0.0, shifty=0.0, winside, viewfac; + short is_ortho= FALSE; + + /* question mark */ + (*ycor)= rd->yasp / rd->xasp; + if(rd->mode & R_FIELDS) + (*ycor) *= 2.0f; + + object_camera_intrinsics(camera, &cam, &is_ortho, &shiftx, &shifty, clipsta, clipend, lens, sensor_x, sensor_y, sensor_fit); + + /* ortho only with camera available */ + if(cam && is_ortho) { + if((*sensor_fit)==CAMERA_SENSOR_FIT_AUTO) { + if(rd->xasp*winx >= rd->yasp*winy) viewfac= winx; + else viewfac= (*ycor) * winy; + } + else if((*sensor_fit)==CAMERA_SENSOR_FIT_HOR) { + viewfac= winx; + } + else { /* if((*sensor_fit)==CAMERA_SENSOR_FIT_VERT) { */ + viewfac= (*ycor) * winy; + } + + /* ortho_scale == 1.0 means exact 1 to 1 mapping */ + pixsize= cam->ortho_scale/viewfac; + } + else { + if((*sensor_fit)==CAMERA_SENSOR_FIT_AUTO) { + if(rd->xasp*winx >= rd->yasp*winy) viewfac= ((*lens) * winx) / (*sensor_x); + else viewfac= (*ycor) * ((*lens) * winy) / (*sensor_x); + } + else if((*sensor_fit)==CAMERA_SENSOR_FIT_HOR) { + viewfac= ((*lens) * winx) / (*sensor_x); + } + else { /* if((*sensor_fit)==CAMERA_SENSOR_FIT_VERT) { */ + viewfac= ((*lens) * winy) / (*sensor_y); + } + + pixsize= (*clipsta) / viewfac; + } + + /* viewplane fully centered, zbuffer fills in jittered between -.5 and +.5 */ + winside= MAX2(winx, winy); + + if(cam) { + if(cam->sensor_fit==CAMERA_SENSOR_FIT_HOR) + winside= winx; + else if(cam->sensor_fit==CAMERA_SENSOR_FIT_VERT) + winside= winy; + } + + viewplane->xmin= -0.5f*(float)winx + shiftx*winside; + viewplane->ymin= -0.5f*(*ycor)*(float)winy + shifty*winside; + viewplane->xmax= 0.5f*(float)winx + shiftx*winside; + viewplane->ymax= 0.5f*(*ycor)*(float)winy + shifty*winside; + + if(field_second) { + if(rd->mode & R_ODDFIELD) { + viewplane->ymin-= 0.5f * (*ycor); + viewplane->ymax-= 0.5f * (*ycor); + } + else { + viewplane->ymin+= 0.5f * (*ycor); + viewplane->ymax+= 0.5f * (*ycor); + } + } + /* the window matrix is used for clipping, and not changed during OSA steps */ + /* using an offset of +0.5 here would give clip errors on edges */ + viewplane->xmin *= pixsize; + viewplane->xmax *= pixsize; + viewplane->ymin *= pixsize; + viewplane->ymax *= pixsize; + + (*viewdx)= pixsize; + (*viewdy)= (*ycor) * pixsize; + + if(is_ortho) + orthographic_m4(winmat, viewplane->xmin, viewplane->xmax, viewplane->ymin, viewplane->ymax, *clipsta, *clipend); + else + perspective_m4(winmat, viewplane->xmin, viewplane->xmax, viewplane->ymin, viewplane->ymax, *clipsta, *clipend); + +} + +void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const short do_clip, const float scale[3], + float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]) +{ + float facx, facy; + float depth; + + /* aspect correcton */ + if (scene) { + float aspx= (float) scene->r.xsch*scene->r.xasp; + float aspy= (float) scene->r.ysch*scene->r.yasp; + + if(camera->sensor_fit==CAMERA_SENSOR_FIT_AUTO) { + if(aspx < aspy) { + r_asp[0]= aspx / aspy; + r_asp[1]= 1.0; + } + else { + r_asp[0]= 1.0; + r_asp[1]= aspy / aspx; + } + } + else if(camera->sensor_fit==CAMERA_SENSOR_FIT_AUTO) { + r_asp[0]= aspx / aspy; + r_asp[1]= 1.0; + } + else { + r_asp[0]= 1.0; + r_asp[1]= aspy / aspx; + } + } + else { + r_asp[0]= 1.0f; + r_asp[1]= 1.0f; + } + + if(camera->type==CAM_ORTHO) { + facx= 0.5f * camera->ortho_scale * r_asp[0] * scale[0]; + facy= 0.5f * camera->ortho_scale * r_asp[1] * scale[1]; + r_shift[0]= camera->shiftx * camera->ortho_scale * scale[0]; + r_shift[1]= camera->shifty * camera->ortho_scale * scale[1]; + depth= do_clip ? -((camera->clipsta * scale[2]) + 0.1f) : - drawsize * camera->ortho_scale * scale[2]; + + *r_drawsize= 0.5f * camera->ortho_scale; + } + else { + /* that way it's always visible - clipsta+0.1 */ + float fac; + float half_sensor= 0.5f*((camera->sensor_fit==CAMERA_SENSOR_FIT_VERT) ? (camera->sensor_y) : (camera->sensor_x)); + + *r_drawsize= drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f); + + if(do_clip) { + /* fixed depth, variable size (avoids exceeding clipping range) */ + depth = -(camera->clipsta + 0.1f); + fac = depth / (camera->lens/(-half_sensor) * scale[2]); + } + else { + /* fixed size, variable depth (stays a reasonable size in the 3D view) */ + depth= *r_drawsize * camera->lens/(-half_sensor) * scale[2]; + fac= *r_drawsize; + } + + facx= fac * r_asp[0] * scale[0]; + facy= fac * r_asp[1] * scale[1]; + r_shift[0]= camera->shiftx*fac*2 * scale[0]; + r_shift[1]= camera->shifty*fac*2 * scale[1]; + } + + r_vec[0][0]= r_shift[0] + facx; r_vec[0][1]= r_shift[1] + facy; r_vec[0][2]= depth; + r_vec[1][0]= r_shift[0] + facx; r_vec[1][1]= r_shift[1] - facy; r_vec[1][2]= depth; + r_vec[2][0]= r_shift[0] - facx; r_vec[2][1]= r_shift[1] - facy; r_vec[2][2]= depth; + r_vec[3][0]= r_shift[0] - facx; r_vec[3][1]= r_shift[1] + facy; r_vec[3][2]= depth; +} + +void camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3]) +{ + float dummy_asp[2]; + float dummy_shift[2]; + float dummy_drawsize; + const float dummy_scale[3]= {1.0f, 1.0f, 1.0f}; + + camera_view_frame_ex(scene, camera, FALSE, 1.0, dummy_scale, + dummy_asp, dummy_shift, &dummy_drawsize, r_vec); +} + diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 21d84245610..56f92b44227 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -449,7 +449,8 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat } else { /* when not in EditMode, use the 'final' derived mesh, depsgraph - * ensures we build with CD_MDEFORMVERT layer */ + * ensures we build with CD_MDEFORMVERT layer + */ dm = (DerivedMesh *)ob->derivedFinal; } diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index d65f08ed7a3..75898018a2b 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -273,7 +273,7 @@ static int cdf_write_header(CDataFile *cdf) return 1; } -int cdf_read_open(CDataFile *cdf, char *filename) +int cdf_read_open(CDataFile *cdf, const char *filename) { FILE *f; @@ -341,7 +341,7 @@ void cdf_read_close(CDataFile *cdf) } } -int cdf_write_open(CDataFile *cdf, char *filename) +int cdf_write_open(CDataFile *cdf, const char *filename) { CDataFileHeader *header; CDataFileImageHeader *image; @@ -405,14 +405,14 @@ void cdf_write_close(CDataFile *cdf) } } -void cdf_remove(char *filename) +void cdf_remove(const char *filename) { BLI_delete(filename, 0, 0); } /********************************** Layers ***********************************/ -CDataFileLayer *cdf_layer_find(CDataFile *cdf, int type, char *name) +CDataFileLayer *cdf_layer_find(CDataFile *cdf, int type, const char *name) { CDataFileLayer *layer; int a; @@ -427,7 +427,7 @@ CDataFileLayer *cdf_layer_find(CDataFile *cdf, int type, char *name) return NULL; } -CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, char *name, size_t datasize) +CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t datasize) { CDataFileLayer *newlayer, *layer; diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 9d51571346f..51edee9ea71 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -591,9 +591,9 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if(part->ren_as == PART_DRAW_OB && part->dup_ob) { node2 = dag_get_node(dag, part->dup_ob); - dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Object Visualisation"); + dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Object Visualisation"); if(part->dup_ob->type == OB_MBALL) - dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA, "Particle Object Visualisation"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA, "Particle Object Visualisation"); } if(part->ren_as == PART_DRAW_GR && part->dup_group) { @@ -799,6 +799,7 @@ DagNode * dag_find_node (DagForest *forest,void * fob) } static int ugly_hack_sorry= 1; // prevent type check +static int dag_print_dependencies= 0; // debugging /* no checking of existence, use dag_find_node first or dag_get_node */ DagNode * dag_add_node (DagForest *forest, void * fob) @@ -926,7 +927,6 @@ static const char *dag_node_name(DagNode *node) return ((bPoseChannel*)(node->ob))->name; } -#if 0 static void dag_node_print_dependencies(DagNode *node) { DagAdjList *itA; @@ -937,7 +937,6 @@ static void dag_node_print_dependencies(DagNode *node) printf(" %s through %s\n", dag_node_name(itA->node), itA->name); printf("\n"); } -#endif static int dag_node_print_dependency_recurs(DagNode *node, DagNode *endnode) { @@ -998,6 +997,11 @@ static void dag_check_cycle(DagForest *dag) DagNode *node; DagAdjList *itA; + /* debugging print */ + if(dag_print_dependencies) + for(node = dag->DagNode.first; node; node= node->next) + dag_node_print_dependencies(node); + /* tag nodes unchecked */ for(node = dag->DagNode.first; node; node= node->next) node->color= DAG_WHITE; @@ -2834,5 +2838,22 @@ void DAG_pose_sort(Object *ob) ugly_hack_sorry= 1; } +/* ************************ DAG DEBUGGING ********************* */ +void DAG_print_dependencies(Main *bmain, Scene *scene, Object *ob) +{ + /* utility for debugging dependencies */ + dag_print_dependencies= 1; + + if(ob && (ob->mode & OB_MODE_POSE)) { + printf("\nDEPENDENCY RELATIONS for %s\n\n", ob->id.name+2); + DAG_pose_sort(ob); + } + else { + printf("\nDEPENDENCY RELATIONS for %s\n\n", scene->id.name+2); + DAG_scene_sort(bmain, scene); + } + + dag_print_dependencies= 0; +} diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 474b3a5ce63..5ab997d2c54 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -184,7 +184,7 @@ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *pro char *path; if(driven) - *driven = 0; + *driven = FALSE; /* only use the current action ??? */ if (ELEM(NULL, adt, adt->action)) @@ -205,7 +205,7 @@ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *pro if ((fcu == NULL) && (adt->drivers.first)) { fcu= list_find_fcurve(&adt->drivers, path, index); if(fcu && driven) - *driven = 1; + *driven = TRUE; fcu = NULL; } diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index cd025ecb559..76c3e6e5502 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -276,8 +276,9 @@ void group_tag_recalc(Group *group) int group_is_animated(Object *parent, Group *group) { GroupObject *go; - - if(give_timeoffset(parent) != 0.0f || parent->nlastrips.first) + + // XXX: old animsys depreceated... + if(parent->nlastrips.first) return 1; for(go= group->gobject.first; go; go= go->next) @@ -343,12 +344,11 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group * but when its enabled at some point it will need to be changed so as not to update so much - campbell */ /* if animated group... */ - if(give_timeoffset(parent) != 0.0f || parent->nlastrips.first) { + if(parent->nlastrips.first) { int cfrao; /* switch to local time */ cfrao= scene->r.cfra; - scene->r.cfra -= (int)floor(give_timeoffset(parent) + 0.5f); /* we need a DAG per group... */ for(go= group->gobject.first; go; go= go->next) { diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 86379db6eea..cdc90cbb788 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -60,6 +60,7 @@ #include "BKE_main.h" #include "BKE_object.h" #include "BKE_deform.h" +#include "BKE_scene.h" #include "RNA_access.h" @@ -1120,7 +1121,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int for(a=0; a<tot; a+=step, cfra+= delta) { - ctime= bsystem_time(scene, NULL, cfra, 0.0); // xxx ugly cruft! + ctime= BKE_curframe(scene); #if 0 // XXX old animation system if(calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) { ctime /= 100.0; @@ -1154,7 +1155,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int } } else { - ctime= bsystem_time(scene, ob, (float)scene->r.cfra, 0.0f); // xxx old cruft + ctime= BKE_curframe(scene); #if 0 // XXX old animation system if(calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) { @@ -1252,7 +1253,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in while (a < estep) { if (remain <= 0) { cfra+= delta; - ctime= bsystem_time(scene, NULL, cfra, 0.0f); // XXX old cruft + ctime= BKE_curframe(scene); ctime /= 100.0f; CLAMP(ctime, 0.0f, 1.0f); // XXX for compat, we use this, but this clamping was confusing @@ -1279,7 +1280,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in } else { - ctime= bsystem_time(scene, NULL, (float)scene->r.cfra, 0.0); + ctime= BKE_curframe(scene); if(key->type==KEY_RELATIVE) { do_rel_cu_key(cu, cu->key, actkb, ctime, out, tot); @@ -1315,7 +1316,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int for(a=0; a<tot; a++, cfra+= delta) { - ctime= bsystem_time(scene, NULL, cfra, 0.0); // XXX old cruft + ctime= BKE_curframe(scene); #if 0 // XXX old animation system if(calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) { ctime /= 100.0; @@ -1346,7 +1347,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int } } else { - ctime= bsystem_time(scene, NULL, (float)scene->r.cfra, 0.0); + ctime= BKE_curframe(scene); #if 0 // XXX old animation system if(calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) { @@ -1511,7 +1512,7 @@ KeyBlock *add_keyblock(Key *key, const char *name) kb->pos= curpos + 0.1f; else { #if 0 // XXX old animation system - curpos= bsystem_time(scene, 0, (float)CFRA, 0.0); + curpos= BKE_curframe(scene); if(calc_ipo_spec(key->ipo, KEY_SPEED, &curpos)==0) { curpos /= 100.0; } diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c new file mode 100644 index 00000000000..974aa660e9f --- /dev/null +++ b/source/blender/blenkernel/intern/lamp.c @@ -0,0 +1,233 @@ +/* + * ***** 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) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/lamp.c + * \ingroup bke + */ + +#include <stdlib.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_lamp_types.h" +#include "DNA_material_types.h" +#include "DNA_object_types.h" +#include "DNA_texture_types.h" + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BKE_animsys.h" +#include "BKE_colortools.h" +#include "BKE_icons.h" +#include "BKE_global.h" +#include "BKE_lamp.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_node.h" + +void *add_lamp(const char *name) +{ + Lamp *la; + + la= alloc_libblock(&G.main->lamp, ID_LA, name); + + la->r= la->g= la->b= la->k= 1.0f; + la->haint= la->energy= 1.0f; + la->dist= 25.0f; + la->spotsize= 45.0f; + la->spotblend= 0.15f; + la->att2= 1.0f; + la->mode= LA_SHAD_BUF; + la->bufsize= 512; + la->clipsta= 0.5f; + la->clipend= 40.0f; + la->shadspotsize= 45.0f; + la->samp= 3; + la->bias= 1.0f; + la->soft= 3.0f; + la->compressthresh= 0.05f; + la->ray_samp= la->ray_sampy= la->ray_sampz= 1; + la->area_size=la->area_sizey=la->area_sizez= 1.0f; + la->buffers= 1; + la->buftype= LA_SHADBUF_HALFWAY; + la->ray_samp_method = LA_SAMP_HALTON; + la->adapt_thresh = 0.001f; + la->preview=NULL; + la->falloff_type = LA_FALLOFF_INVSQUARE; + la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); + la->sun_effect_type = 0; + la->horizon_brightness = 1.0; + la->spread = 1.0; + la->sun_brightness = 1.0; + la->sun_size = 1.0; + la->backscattered_light = 1.0f; + la->atm_turbidity = 2.0f; + la->atm_inscattering_factor = 1.0f; + la->atm_extinction_factor = 1.0f; + la->atm_distance_factor = 1.0f; + la->sun_intensity = 1.0f; + la->skyblendtype= MA_RAMP_ADD; + la->skyblendfac= 1.0f; + la->sky_colorspace= BLI_XYZ_CIE; + la->sky_exposure= 1.0f; + + curvemapping_initialize(la->curfalloff); + return la; +} + +Lamp *copy_lamp(Lamp *la) +{ + Lamp *lan; + int a; + + lan= copy_libblock(la); + + for(a=0; a<MAX_MTEX; a++) { + if(lan->mtex[a]) { + lan->mtex[a]= MEM_mallocN(sizeof(MTex), "copylamptex"); + memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex)); + id_us_plus((ID *)lan->mtex[a]->tex); + } + } + + lan->curfalloff = curvemapping_copy(la->curfalloff); + + if(la->nodetree) + lan->nodetree= ntreeCopyTree(la->nodetree); + + 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->nodetree) + lan->nodetree= ntreeLocalize(la->nodetree); + + lan->preview= NULL; + + return lan; +} + +void make_local_lamp(Lamp *la) +{ + Main *bmain= G.main; + Object *ob; + int is_local= FALSE, is_lib= FALSE; + + /* - only lib users: do nothing + * - only local users: set flag + * - mixed: make copy + */ + + if(la->id.lib==NULL) return; + if(la->id.us==1) { + id_clear_lib_data(bmain, &la->id); + return; + } + + ob= bmain->object.first; + while(ob) { + if(ob->data==la) { + if(ob->id.lib) is_lib= TRUE; + else is_local= TRUE; + } + ob= ob->id.next; + } + + if(is_local && is_lib == FALSE) { + id_clear_lib_data(bmain, &la->id); + } + else if(is_local && is_lib) { + Lamp *lan= copy_lamp(la); + lan->id.us= 0; + + /* Remap paths of new ID using old library as base. */ + BKE_id_lib_local_paths(bmain, &lan->id); + + ob= bmain->object.first; + while(ob) { + if(ob->data==la) { + + if(ob->id.lib==NULL) { + ob->data= lan; + lan->id.us++; + la->id.us--; + } + } + ob= ob->id.next; + } + } +} + +void free_lamp(Lamp *la) +{ + MTex *mtex; + int a; + + for(a=0; a<MAX_MTEX; a++) { + mtex= la->mtex[a]; + if(mtex && mtex->tex) mtex->tex->id.us--; + if(mtex) MEM_freeN(mtex); + } + + BKE_free_animdata((ID *)la); + + curvemapping_free(la->curfalloff); + + /* is no lib link block, but lamp extension */ + if(la->nodetree) { + ntreeFreeTree(la->nodetree); + MEM_freeN(la->nodetree); + } + + BKE_previewimg_free(&la->preview); + BKE_icon_delete(&la->id); + la->id.icon_id = 0; +} + diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 47878242604..cef23ac3824 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -658,7 +658,9 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C return 0; } -void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3], int numVerts, char *vgroup, short defaxis) +void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, + DerivedMesh *dm, float (*vertexCos)[3], + int numVerts, const char *vgroup, short defaxis) { Curve *cu; int a, flag; @@ -817,7 +819,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, float *orco } void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts, char *vgroup) + float (*vertexCos)[3], int numVerts, const char *vgroup) { int a; int use_vgroups; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 9368430187d..4259e11d340 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -77,7 +77,9 @@ #include "BLI_bpath.h" #include "BKE_animsys.h" +#include "BKE_camera.h" #include "BKE_context.h" +#include "BKE_lamp.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index bd004ce21f2..483eebb3dcb 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -42,7 +42,6 @@ #include "DNA_constraint_types.h" #include "DNA_group_types.h" #include "DNA_key_types.h" -#include "DNA_lamp_types.h" #include "DNA_lattice_types.h" #include "DNA_material_types.h" #include "DNA_meta_types.h" @@ -81,6 +80,7 @@ #include "BKE_group.h" #include "BKE_icons.h" #include "BKE_key.h" +#include "BKE_lamp.h" #include "BKE_lattice.h" #include "BKE_library.h" #include "BKE_mesh.h" @@ -99,6 +99,7 @@ #include "BKE_speaker.h" #include "BKE_softbody.h" #include "BKE_material.h" +#include "BKE_camera.h" #include "LBM_fluidsim.h" @@ -304,8 +305,6 @@ void free_object(Object *ob) ob->matbits= NULL; if(ob->bb) MEM_freeN(ob->bb); ob->bb= NULL; - if(ob->path) free_path(ob->path); - ob->path= NULL; if(ob->adt) BKE_free_animdata((ID *)ob); if(ob->poselib) ob->poselib->id.us--; if(ob->gpd) ((ID *)ob->gpd)->us--; @@ -718,286 +717,6 @@ int exist_object(Object *obtest) return 0; } -void *add_camera(const char *name) -{ - Camera *cam; - - cam= alloc_libblock(&G.main->camera, ID_CA, name); - - cam->lens= 35.0f; - cam->clipsta= 0.1f; - cam->clipend= 100.0f; - cam->drawsize= 0.5f; - cam->ortho_scale= 6.0; - cam->flag |= CAM_SHOWPASSEPARTOUT; - cam->passepartalpha = 0.5f; - - return cam; -} - -Camera *copy_camera(Camera *cam) -{ - Camera *camn; - - camn= copy_libblock(cam); - - return camn; -} - - - -void make_local_camera(Camera *cam) -{ - Main *bmain= G.main; - Object *ob; - int is_local= FALSE, is_lib= FALSE; - - /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ - - if(cam->id.lib==NULL) return; - if(cam->id.us==1) { - id_clear_lib_data(bmain, &cam->id); - return; - } - - for(ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) { - if(ob->data==cam) { - if(ob->id.lib) is_lib= TRUE; - else is_local= TRUE; - } - } - - if(is_local && is_lib == FALSE) { - id_clear_lib_data(bmain, &cam->id); - } - else if(is_local && is_lib) { - Camera *camn= copy_camera(cam); - - camn->id.us= 0; - - /* Remap paths of new ID using old library as base. */ - BKE_id_lib_local_paths(bmain, &camn->id); - - for(ob= bmain->object.first; ob; ob= ob->id.next) { - if(ob->data == cam) { - if(ob->id.lib==NULL) { - ob->data= camn; - camn->id.us++; - cam->id.us--; - } - } - } - } -} - -/* get the camera's dof value, takes the dof object into account */ -float dof_camera(Object *ob) -{ - Camera *cam = (Camera *)ob->data; - if (ob->type != OB_CAMERA) - return 0.0f; - if (cam->dof_ob) { - /* too simple, better to return the distance on the view axis only - * return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */ - float mat[4][4], imat[4][4], obmat[4][4]; - - copy_m4_m4(obmat, ob->obmat); - normalize_m4(obmat); - invert_m4_m4(imat, obmat); - mul_m4_m4m4(mat, cam->dof_ob->obmat, imat); - return (float)fabs(mat[3][2]); - } - return cam->YF_dofdist; -} - -void *add_lamp(const char *name) -{ - Lamp *la; - - la= alloc_libblock(&G.main->lamp, ID_LA, name); - - la->r= la->g= la->b= la->k= 1.0f; - la->haint= la->energy= 1.0f; - la->dist= 25.0f; - la->spotsize= 45.0f; - la->spotblend= 0.15f; - la->att2= 1.0f; - la->mode= LA_SHAD_BUF; - la->bufsize= 512; - la->clipsta= 0.5f; - la->clipend= 40.0f; - la->shadspotsize= 45.0f; - la->samp= 3; - la->bias= 1.0f; - la->soft= 3.0f; - la->compressthresh= 0.05f; - la->ray_samp= la->ray_sampy= la->ray_sampz= 1; - la->area_size=la->area_sizey=la->area_sizez= 1.0f; - la->buffers= 1; - la->buftype= LA_SHADBUF_HALFWAY; - la->ray_samp_method = LA_SAMP_HALTON; - la->adapt_thresh = 0.001f; - la->preview=NULL; - la->falloff_type = LA_FALLOFF_INVSQUARE; - la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); - la->sun_effect_type = 0; - la->horizon_brightness = 1.0; - la->spread = 1.0; - la->sun_brightness = 1.0; - la->sun_size = 1.0; - la->backscattered_light = 1.0f; - la->atm_turbidity = 2.0f; - la->atm_inscattering_factor = 1.0f; - la->atm_extinction_factor = 1.0f; - la->atm_distance_factor = 1.0f; - la->sun_intensity = 1.0f; - la->skyblendtype= MA_RAMP_ADD; - la->skyblendfac= 1.0f; - la->sky_colorspace= BLI_XYZ_CIE; - la->sky_exposure= 1.0f; - - curvemapping_initialize(la->curfalloff); - return la; -} - -Lamp *copy_lamp(Lamp *la) -{ - Lamp *lan; - int a; - - lan= copy_libblock(la); - - for(a=0; a<MAX_MTEX; a++) { - if(lan->mtex[a]) { - lan->mtex[a]= MEM_mallocN(sizeof(MTex), "copylamptex"); - memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex)); - id_us_plus((ID *)lan->mtex[a]->tex); - } - } - - lan->curfalloff = curvemapping_copy(la->curfalloff); - - if(la->nodetree) - lan->nodetree= ntreeCopyTree(la->nodetree); - - 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->nodetree) - lan->nodetree= ntreeLocalize(la->nodetree); - - lan->preview= NULL; - - return lan; -} - -void make_local_lamp(Lamp *la) -{ - Main *bmain= G.main; - Object *ob; - int is_local= FALSE, is_lib= FALSE; - - /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ - - if(la->id.lib==NULL) return; - if(la->id.us==1) { - id_clear_lib_data(bmain, &la->id); - return; - } - - ob= bmain->object.first; - while(ob) { - if(ob->data==la) { - if(ob->id.lib) is_lib= TRUE; - else is_local= TRUE; - } - ob= ob->id.next; - } - - if(is_local && is_lib == FALSE) { - id_clear_lib_data(bmain, &la->id); - } - else if(is_local && is_lib) { - Lamp *lan= copy_lamp(la); - lan->id.us= 0; - - /* Remap paths of new ID using old library as base. */ - BKE_id_lib_local_paths(bmain, &lan->id); - - ob= bmain->object.first; - while(ob) { - if(ob->data==la) { - - if(ob->id.lib==NULL) { - ob->data= lan; - lan->id.us++; - la->id.us--; - } - } - ob= ob->id.next; - } - } -} - -void free_camera(Camera *ca) -{ - BKE_free_animdata((ID *)ca); -} - -void free_lamp(Lamp *la) -{ - MTex *mtex; - int a; - - for(a=0; a<MAX_MTEX; a++) { - mtex= la->mtex[a]; - if(mtex && mtex->tex) mtex->tex->id.us--; - if(mtex) MEM_freeN(mtex); - } - - BKE_free_animdata((ID *)la); - - curvemapping_free(la->curfalloff); - - /* is no lib link block, but lamp extension */ - if(la->nodetree) { - ntreeFreeTree(la->nodetree); - MEM_freeN(la->nodetree); - } - - BKE_previewimg_free(&la->preview); - BKE_icon_delete(&la->id); - la->id.icon_id = 0; -} - /* *************************************************** */ static void *add_obdata_from_type(int type) @@ -1106,7 +825,6 @@ Object *add_only_object(int type, const char *name) ob->obstacleRad = 1.; /* NT fluid sim defaults */ - ob->fluidsimFlag = 0; ob->fluidsimSettings = NULL; ob->pc_ids.first = ob->pc_ids.last = NULL; @@ -1376,7 +1094,6 @@ Object *copy_object(Object *ob) } if(ob->bb) obn->bb= MEM_dupallocN(ob->bb); - obn->path= NULL; obn->flag &= ~OB_FROMGROUP; obn->modifiers.first = obn->modifiers.last= NULL; @@ -1703,33 +1420,6 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) /* *************** CALC ****************** */ -/* there is also a timing calculation in drawobject() */ - - -// XXX THIS CRUFT NEEDS SERIOUS RECODING ASAP! -/* ob can be NULL */ -float bsystem_time(struct Scene *scene, Object *UNUSED(ob), float cfra, float ofs) -{ - /* returns float ( see BKE_curframe in scene.c) */ - cfra += scene->r.subframe; - - /* global time */ - if (scene) - cfra*= scene->r.framelen; - -#if 0 // XXX old animation system - if (ob) { - /* ofset frames */ - if ((ob->ipoflag & OB_OFFS_PARENT) && (ob->partype & PARSLOW)==0) - cfra-= give_timeoffset(ob); - } -#endif // XXX old animation system - - cfra-= ofs; - - return cfra; -} - void object_scale_to_mat3(Object *ob, float mat[][3]) { float vec[3]; @@ -1737,7 +1427,6 @@ void object_scale_to_mat3(Object *ob, float mat[][3]) size_to_mat3( mat,vec); } - void object_rot_to_mat3(Object *ob, float mat[][3]) { float rmat[3][3], dmat[3][3]; @@ -1876,12 +1565,6 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) makeDispListCurveTypes(scene, par, 0); if(cu->path==NULL) return; - /* exception, timeoffset is regarded as distance offset */ - if(cu->flag & CU_OFFS_PATHDIST) { - timeoffs = give_timeoffset(ob); - SWAP(float, sf_orig, ob->sf); - } - /* catch exceptions: feature for nla stride editing */ if(ob->ipoflag & OB_DISABLE_PATH) { ctime= 0.0f; @@ -1902,7 +1585,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) CLAMP(ctime, 0.0f, 1.0f); } else { - ctime= scene->r.cfra - give_timeoffset(ob); + ctime= scene->r.cfra; if (IS_EQF(cu->pathlen, 0.0f) == 0) ctime /= cu->pathlen; @@ -2158,9 +1841,6 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) if(ob->parent) { Object *par= ob->parent; - // XXX depreceated - animsys - if(ob->ipoflag & OB_OFFS_PARENT) ctime-= give_timeoffset(ob); - /* hurms, code below conflicts with depgraph... (ton) */ /* and even worse, it gives bad effects for NLA stride too (try ctime != par->ctime, with MBlur) */ if(no_parent_ipo==0 && stime != par->ctime) { @@ -2169,17 +1849,20 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) if(par->proxy_from); // was a copied matrix, no where_is! bad... else where_is_object_time(scene, par, ctime); - + solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); - + *par= tmp; } else solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); + /* "slow parent" is definitely not threadsafe, and may also give bad results jumping around + * An old-fashioned hack which probably doesn't really cut it anymore + */ if(ob->partype & PARSLOW) { // include framerate - fac1= ( 1.0f / (1.0f + (float)fabs(give_timeoffset(ob))) ); + fac1= ( 1.0f / (1.0f + (float)fabs(ob->sf)) ); if(fac1 >= 1.0f) return; fac2= 1.0f-fac1; @@ -2302,7 +1985,6 @@ void where_is_object_simul(Scene *scene, Object *ob) for a lamp that is the child of another object */ { Object *par; - //Ipo *ipo; float *fp1, *fp2; float slowmat[4][4]; float fac1, fac2; @@ -2313,10 +1995,9 @@ for a lamp that is the child of another object */ par= ob->parent; solve_parenting(scene, ob, par, ob->obmat, slowmat, 1); - + if(ob->partype & PARSLOW) { - - fac1= (float)(1.0/(1.0+ fabs(give_timeoffset(ob)))); + fac1= (float)(1.0/(1.0+ fabs(ob->sf))); fac2= 1.0f-fac1; fp1= ob->obmat[0]; fp2= slowmat[0]; @@ -2324,7 +2005,6 @@ for a lamp that is the child of another object */ fp1[0]= fac1*fp1[0] + fac2*fp2[0]; } } - } else { object_to_mat4(ob, ob->obmat); @@ -2847,15 +2527,6 @@ void object_sculpt_modifiers_changed(Object *ob) } } -float give_timeoffset(Object *ob) -{ - if ((ob->ipoflag & OB_OFFS_PARENTADD) && ob->parent) { - return ob->sf + give_timeoffset(ob->parent); - } else { - return ob->sf; - } -} - int give_obdata_texspace(Object *ob, short **texflag, float **loc, float **size, float **rot) { @@ -2954,200 +2625,6 @@ int object_insert_ptcache(Object *ob) return i; } -void object_camera_mode(RenderData *rd, Object *camera) -{ - rd->mode &= ~(R_ORTHO|R_PANORAMA); - if(camera && camera->type==OB_CAMERA) { - Camera *cam= camera->data; - if(cam->type == CAM_ORTHO) rd->mode |= R_ORTHO; - if(cam->flag & CAM_PANORAMA) rd->mode |= R_PANORAMA; - } -} - -/* 'lens' may be set for envmap only */ -void object_camera_matrix( - RenderData *rd, Object *camera, int winx, int winy, short field_second, - float winmat[][4], rctf *viewplane, float *clipsta, float *clipend, float *lens, float *ycor, - float *viewdx, float *viewdy -) { - Camera *cam=NULL; - float pixsize; - float shiftx=0.0, shifty=0.0, winside, viewfac; - short is_ortho= FALSE; - - /* question mark */ - (*ycor)= rd->yasp / rd->xasp; - if(rd->mode & R_FIELDS) - (*ycor) *= 2.0f; - - if(camera->type==OB_CAMERA) { - cam= camera->data; - - if(cam->type == CAM_ORTHO) { - is_ortho= TRUE; - } - - /* solve this too... all time depending stuff is in convertblender.c? - * Need to update the camera early because it's used for projection matrices - * and other stuff BEFORE the animation update loop is done - * */ -#if 0 // XXX old animation system - if(cam->ipo) { - calc_ipo(cam->ipo, frame_to_float(re->scene, re->r.cfra)); - execute_ipo(&cam->id, cam->ipo); - } -#endif // XXX old animation system - shiftx=cam->shiftx; - shifty=cam->shifty; - (*lens)= cam->lens; - (*clipsta)= cam->clipsta; - (*clipend)= cam->clipend; - } - else if(camera->type==OB_LAMP) { - Lamp *la= camera->data; - float fac= cosf((float)M_PI*la->spotsize/360.0f); - float phi= acos(fac); - - (*lens)= 16.0f*fac/sinf(phi); - if((*lens)==0.0f) - (*lens)= 35.0f; - (*clipsta)= la->clipsta; - (*clipend)= la->clipend; - } - else { /* envmap exception... */; - if((*lens)==0.0f) - (*lens)= 16.0f; - - if((*clipsta)==0.0f || (*clipend)==0.0f) { - (*clipsta)= 0.1f; - (*clipend)= 1000.0f; - } - } - - /* ortho only with camera available */ - if(cam && is_ortho) { - if(rd->xasp*winx >= rd->yasp*winy) { - viewfac= winx; - } - else { - viewfac= (*ycor) * winy; - } - /* ortho_scale == 1.0 means exact 1 to 1 mapping */ - pixsize= cam->ortho_scale/viewfac; - } - else { - if(rd->xasp*winx >= rd->yasp*winy) viewfac= ((*lens) * winx)/32.0f; - else viewfac= (*ycor) * ((*lens) * winy)/32.0f; - pixsize= (*clipsta) / viewfac; - } - - /* viewplane fully centered, zbuffer fills in jittered between -.5 and +.5 */ - winside= MAX2(winx, winy); - viewplane->xmin= -0.5f*(float)winx + shiftx*winside; - viewplane->ymin= -0.5f*(*ycor)*(float)winy + shifty*winside; - viewplane->xmax= 0.5f*(float)winx + shiftx*winside; - viewplane->ymax= 0.5f*(*ycor)*(float)winy + shifty*winside; - - if(field_second) { - if(rd->mode & R_ODDFIELD) { - viewplane->ymin-= 0.5f * (*ycor); - viewplane->ymax-= 0.5f * (*ycor); - } - else { - viewplane->ymin+= 0.5f * (*ycor); - viewplane->ymax+= 0.5f * (*ycor); - } - } - /* the window matrix is used for clipping, and not changed during OSA steps */ - /* using an offset of +0.5 here would give clip errors on edges */ - viewplane->xmin *= pixsize; - viewplane->xmax *= pixsize; - viewplane->ymin *= pixsize; - viewplane->ymax *= pixsize; - - (*viewdx)= pixsize; - (*viewdy)= (*ycor) * pixsize; - - if(is_ortho) - orthographic_m4(winmat, viewplane->xmin, viewplane->xmax, viewplane->ymin, viewplane->ymax, *clipsta, *clipend); - else - perspective_m4(winmat, viewplane->xmin, viewplane->xmax, viewplane->ymin, viewplane->ymax, *clipsta, *clipend); - -} - -void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const short do_clip, const float scale[3], - float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]) -{ - float facx, facy; - float depth; - - /* aspect correcton */ - if (scene) { - float aspx= (float) scene->r.xsch*scene->r.xasp; - float aspy= (float) scene->r.ysch*scene->r.yasp; - - if(aspx < aspy) { - r_asp[0]= aspx / aspy; - r_asp[1]= 1.0; - } - else { - r_asp[0]= 1.0; - r_asp[1]= aspy / aspx; - } - } - else { - r_asp[0]= 1.0f; - r_asp[1]= 1.0f; - } - - if(camera->type==CAM_ORTHO) { - facx= 0.5f * camera->ortho_scale * r_asp[0] * scale[0]; - facy= 0.5f * camera->ortho_scale * r_asp[1] * scale[1]; - r_shift[0]= camera->shiftx * camera->ortho_scale * scale[0]; - r_shift[1]= camera->shifty * camera->ortho_scale * scale[1]; - depth= do_clip ? -((camera->clipsta * scale[2]) + 0.1f) : - drawsize * camera->ortho_scale * scale[2]; - - *r_drawsize= 0.5f * camera->ortho_scale; - } - else { - /* that way it's always visible - clipsta+0.1 */ - float fac; - *r_drawsize= drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f); - - if(do_clip) { - /* fixed depth, variable size (avoids exceeding clipping range) */ - depth = -(camera->clipsta + 0.1f); - fac = depth / (camera->lens/-16.0f * scale[2]); - } - else { - /* fixed size, variable depth (stays a reasonable size in the 3D view) */ - depth= *r_drawsize * camera->lens/-16.0f * scale[2]; - fac= *r_drawsize; - } - - facx= fac * r_asp[0] * scale[0]; - facy= fac * r_asp[1] * scale[1]; - r_shift[0]= camera->shiftx*fac*2 * scale[0]; - r_shift[1]= camera->shifty*fac*2 * scale[1]; - } - - r_vec[0][0]= r_shift[0] + facx; r_vec[0][1]= r_shift[1] + facy; r_vec[0][2]= depth; - r_vec[1][0]= r_shift[0] + facx; r_vec[1][1]= r_shift[1] - facy; r_vec[1][2]= depth; - r_vec[2][0]= r_shift[0] - facx; r_vec[2][1]= r_shift[1] - facy; r_vec[2][2]= depth; - r_vec[3][0]= r_shift[0] - facx; r_vec[3][1]= r_shift[1] + facy; r_vec[3][2]= depth; -} - -void camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3]) -{ - float dummy_asp[2]; - float dummy_shift[2]; - float dummy_drawsize; - const float dummy_scale[3]= {1.0f, 1.0f, 1.0f}; - - camera_view_frame_ex(scene, camera, FALSE, 1.0, dummy_scale, - dummy_asp, dummy_shift, &dummy_drawsize, r_vec); -} - #if 0 static int pc_findindex(ListBase *listbase, int index) { diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index ec20e9390cd..d6c0638ba62 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -79,6 +79,7 @@ #include "BKE_mesh.h" #include "BKE_cdderivedmesh.h" #include "BKE_pointcache.h" +#include "BKE_scene.h" #include "RE_render_ext.h" @@ -3428,7 +3429,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->totpart=0; psys->flag = PSYS_ENABLED|PSYS_CURRENT; - psys->cfra=bsystem_time(scene,ob,scene->r.cfra+1,0.0); + psys->cfra = BKE_nextframe(scene); DAG_scene_sort(G.main, scene); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -4190,7 +4191,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta float timestep = psys_get_timestep(sim); /* negative time means "use current time" */ - cfra = state->time > 0 ? state->time : bsystem_time(sim->scene, 0, (float)sim->scene->r.cfra, 0.0); + cfra = state->time > 0 ? state->time : BKE_curframe(sim->scene); if(p>=totpart){ if(!psys->totchild) diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index fa9d94eb24d..7a8162391d5 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2147,8 +2147,8 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra cache= pid->cache; if(timescale) { - time= bsystem_time(scene, ob, cfra, 0.0f); - nexttime= bsystem_time(scene, ob, cfra+1.0f, 0.0f); + time= BKE_curframe(scene); + nexttime= BKE_nextframe(scene); *timescale= MAX2(nexttime - time, 0.0f); } @@ -2163,7 +2163,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra * system timing. */ #if 0 if ((ob->partype & PARSLOW)==0) { - offset= give_timeoffset(ob); + offset= ob->sf; *startframe += (int)(offset+0.5f); *endframe += (int)(offset+0.5f); @@ -2875,7 +2875,7 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) BKE_ptcache_update_info(pid); } -void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to) +void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const char *name_dst) { char old_name[80]; int len; /* store the length of the string */ @@ -2892,7 +2892,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to) BLI_strncpy(old_name, pid->cache->name, sizeof(old_name)); /* get "from" filename */ - BLI_strncpy(pid->cache->name, from, sizeof(pid->cache->name)); + BLI_strncpy(pid->cache->name, name_src, sizeof(pid->cache->name)); len = ptcache_filename(pid, old_filename, 0, 0, 0); /* no path */ @@ -2906,7 +2906,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to) BLI_snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index); /* put new name into cache */ - BLI_strncpy(pid->cache->name, to, sizeof(pid->cache->name)); + BLI_strncpy(pid->cache->name, name_dst, sizeof(pid->cache->name)); while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index f9d470e48d8..d6c4b5f3a2e 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -200,7 +200,7 @@ void set_ob_property(Object *ob, bProperty *propc) /* negative: prop is smaller * positive: prop is larger */ -int compare_property(bProperty *prop, char *str) +int compare_property(bProperty *prop, const char *str) { // extern int Gdfra; /* sector.c */ float fvalue, ftest; @@ -237,7 +237,7 @@ int compare_property(bProperty *prop, char *str) return 0; } -void set_property(bProperty *prop, char *str) +void set_property(bProperty *prop, const char *str) { // extern int Gdfra; /* sector.c */ @@ -261,7 +261,7 @@ void set_property(bProperty *prop, char *str) } -void add_property(bProperty *prop, char *str) +void add_property(bProperty *prop, const char *str) { // extern int Gdfra; /* sector.c */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index a9de75dc7d0..2f24b7e735d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -806,6 +806,8 @@ int scene_camera_switch_update(Scene *scene) scene->camera= camera; return 1; } +#else + (void)scene; #endif return 0; } @@ -908,14 +910,23 @@ int scene_check_setscene(Main *bmain, Scene *sce) } /* This function is needed to cope with fractional frames - including two Blender rendering features -* mblur (motion blur that renders 'subframes' and blurs them together), and fields rendering. */ - -/* see also bsystem_time in object.c */ + * mblur (motion blur that renders 'subframes' and blurs them together), and fields rendering. + */ float BKE_curframe(Scene *scene) { float ctime = scene->r.cfra; - ctime+= scene->r.subframe; - ctime*= scene->r.framelen; + ctime += scene->r.subframe; + ctime *= scene->r.framelen; + + return ctime; +} + +/* Similar to BKE_curframe(), but is used by physics sims to get "next time", which is defined as cfra+1 */ +float BKE_nextframe(Scene *scene) +{ + float ctime = (float)(scene->r.cfra + 1); + ctime += scene->r.subframe; + ctime *= scene->r.framelen; return ctime; } diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 02e6fe945f3..3d28e45f6b7 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -351,6 +351,29 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type) return NULL; } +/* note, using this function is generally a last resort, you really want to be + * using the context when you can - campbell + * -1 for any type */ +struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min) +{ + ScrArea *sa, *big= NULL; + int size, maxsize= 0; + + for(sa= sc->areabase.first; sa; sa= sa->next) { + if ((spacetype == -1) || sa->spacetype == spacetype) { + if (min <= sa->winx && min <= sa->winy) { + size= sa->winx*sa->winy; + if (size > maxsize) { + maxsize= size; + big= sa; + } + } + } + } + + return big; +} + void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene) { int bit; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 6b319e6b5e1..3e9b570d104 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1980,6 +1980,8 @@ static ImBuf * seq_render_scene_strip_impl( /* stooping to new low's in hackyness :( */ oldmarkers= scene->markers; scene->markers.first= scene->markers.last= NULL; +#else + (void)oldmarkers; #endif if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (scene == context.scene || have_seq==0) && camera) { @@ -3404,7 +3406,7 @@ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs) } } -void seq_dupe_animdata(Scene *scene, char *name_from, char *name_to) +void seq_dupe_animdata(Scene *scene, const char *name_src, const char *name_dst) { char str_from[32]; FCurve *fcu; @@ -3415,7 +3417,7 @@ void seq_dupe_animdata(Scene *scene, char *name_from, char *name_to) if(scene->adt==NULL || scene->adt->action==NULL) return; - sprintf(str_from, "[\"%s\"]", name_from); + sprintf(str_from, "[\"%s\"]", name_src); fcu_last= scene->adt->action->curves.last; @@ -3427,7 +3429,7 @@ void seq_dupe_animdata(Scene *scene, char *name_from, char *name_to) } /* notice validate is 0, keep this because the seq may not be added to the scene yet */ - BKE_animdata_fix_paths_rename(&scene->id, scene->adt, "sequence_editor.sequences_all", name_from, name_to, 0, 0, 0); + BKE_animdata_fix_paths_rename(&scene->id, scene->adt, "sequence_editor.sequences_all", name_src, name_dst, 0, 0, 0); /* add the original fcurves back */ BLI_movelisttolist(&scene->adt->action->curves, &lb); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 69af2570d0c..955127a8000 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1234,7 +1234,7 @@ char *txt_to_buf (Text *text) return buf; } -int txt_find_string(Text *text, char *findstr, int wrap, int match_case) +int txt_find_string(Text *text, const char *findstr, int wrap, int match_case) { TextLine *tl, *startl; char *s= NULL; diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 01b090f2967..616c27f6b0b 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -426,9 +426,9 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system, } -static char *unit_find_str(char *str, const char *substr) +static const char *unit_find_str(const char *str, const char *substr) { - char *str_found; + const char *str_found; if(substr && substr[0] != '\0') { str_found= strstr(str, substr); @@ -485,7 +485,7 @@ static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pr { char *str_found; - if((len_max>0) && (str_found= unit_find_str(str, replace_str))) { /* XXX - investigate, does not respect len_max properly */ + if((len_max>0) && (str_found= (char *)unit_find_str(str, replace_str))) { /* XXX - investigate, does not respect len_max properly */ int len, len_num, len_name, len_move, found_ofs; found_ofs = (int)(str_found-str); @@ -537,7 +537,7 @@ static int unit_replace(char *str, int len_max, char *str_tmp, double scale_pref return ofs; } -static int unit_find(char *str, bUnitDef *unit) +static int unit_find(const char *str, bUnitDef *unit) { if (unit_find_str(str, unit->name_short)) return 1; if (unit_find_str(str, unit->name_plural)) return 1; @@ -562,7 +562,7 @@ static int unit_find(char *str, bUnitDef *unit) * * return true of a change was made. */ -int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pref, int system, int type) +int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double scale_pref, int system, int type) { bUnitCollection *usys = unit_get_system(system, type); @@ -676,7 +676,7 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre } /* 45µm --> 45um */ -void bUnit_ToUnitAltName(char *str, int len_max, char *orig_str, int system, int type) +void bUnit_ToUnitAltName(char *str, int len_max, const char *orig_str, int system, int type) { bUnitCollection *usys = unit_get_system(system, type); @@ -687,9 +687,7 @@ void bUnit_ToUnitAltName(char *str, int len_max, char *orig_str, int system, int for(unit= usys->units; unit->name; unit++) { if(len_max > 0 && (unit->name_alt || unit == unit_def)) { - char *found= NULL; - - found= unit_find_str(orig_str, unit->name_short); + const char *found= unit_find_str(orig_str, unit->name_short); if(found) { int offset= (int)(found - orig_str); int len_name= 0; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index da1412dac0d..2646f5164b2 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1046,7 +1046,7 @@ void ffmpeg_property_del(RenderData *rd, void *type, void *prop_) } } -IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int parent_index) +IDProperty *ffmpeg_property_add(RenderData *rd, const char *type, int opt_index, int parent_index) { AVCodecContext c; const AVOption * o; diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index aef1c4bb46c..fca7c3469a1 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -179,8 +179,8 @@ void dquat_to_mat4(float R[4][4], DualQuat *dq); void quat_apply_track(float quat[4], short axis, short upflag); void vec_apply_track(float vec[3], short axis); -float lens_to_angle(float lens); -float angle_to_lens(float angle); +float focallength_to_fov(float focal_length, float sensor); +float fov_to_focallength(float fov, float sensor); float angle_wrap_rad(float angle); float angle_wrap_deg(float angle); diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 0ca8b72c1e3..7fecbae8229 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1688,14 +1688,14 @@ void vec_apply_track(float vec[3], short axis) } /* lens/angle conversion (radians) */ -float lens_to_angle(float lens) +float focallength_to_fov(float focal_length, float sensor) { - return 2.0f * atanf(16.0f/lens); + return 2.0f * atanf((sensor/2.0f) / focal_length); } -float angle_to_lens(float angle) +float fov_to_focallength(float hfov, float sensor) { - return 16.0f / tanf(angle * 0.5f); + return (sensor/2.0f) / tanf(hfov * 0.5f); } /* 'mod_inline(-3,4)= 1', 'fmod(-3,4)= -3' */ diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 6cba79849c2..16cc3c15bfd 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -80,7 +80,7 @@ typedef struct { struct PBVHNode { /* Opaque handle for drawing code */ - void *draw_buffers; + GPU_Buffers *draw_buffers; /* Voxel bounds */ BB vb; diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c index 30625e7b34e..8b00d8e48a6 100644 --- a/source/blender/blenlib/intern/uvproject.c +++ b/source/blender/blenlib/intern/uvproject.c @@ -141,7 +141,7 @@ UvCameraInfo *project_camera_info(Object *ob, float (*rotmat)[4], float winx, fl uci.do_pano = (camera->flag & CAM_PANORAMA); uci.do_persp = (camera->type==CAM_PERSP); - uci.camangle= lens_to_angle(camera->lens) / 2.0f; + uci.camangle= focallength_to_fov(camera->lens, camera->sensor_x) / 2.0f; uci.camsize= uci.do_persp ? tanf(uci.camangle) : camera->ortho_scale; /* account for scaled cameras */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index fe89f6882d4..9e6344573bb 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4605,6 +4605,8 @@ static void lib_link_scene(FileData *fd, Main *main) marker->camera= newlibadr(fd, sce->id.lib, marker->camera); } } +#else + (void)marker; #endif if(sce->ed) @@ -7219,7 +7221,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) while(ob) { if(ob->transflag & 1) { ob->transflag -= 1; - ob->ipoflag |= OB_OFFS_OB; + //ob->ipoflag |= OB_OFFS_OB; } ob= ob->id.next; } @@ -7250,7 +7252,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } ob= main->object.first; while(ob) { - ob->ipoflag |= OB_OFFS_PARENT; + //ob->ipoflag |= OB_OFFS_PARENT; if(ob->dt==0) ob->dt= OB_SOLID; ob= ob->id.next; } @@ -7495,9 +7497,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if(main->versionfile <= 200) { Object *ob= main->object.first; while(ob) { - ob->scaflag = ob->gameflag & (64+128+256+512+1024+2048); + ob->scaflag = ob->gameflag & (OB_DO_FH|OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS); /* 64 is do_fh */ - ob->gameflag &= ~(128+256+512+1024+2048); + ob->gameflag &= ~(OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS); ob = ob->id.next; } } @@ -8311,7 +8313,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if(main->versionfile <= 233) { bScreen *sc; Material *ma= main->mat.first; - Object *ob= main->object.first; + /* Object *ob= main->object.first; */ while(ma) { if(ma->rampfac_col==0.0f) ma->rampfac_col= 1.0; @@ -8321,11 +8323,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } /* this should have been done loooong before! */ +#if 0 /* deprecated in 2.5+ */ while(ob) { if(ob->ipowin==0) ob->ipowin= ID_OB; ob= ob->id.next; } - +#endif for (sc= main->screen.first; sc; sc= sc->id.next) { ScrArea *sa; for (sa= sc->areabase.first; sa; sa= sa->next) { @@ -12187,8 +12190,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } - /* put compatibility code here until next subversion bump */ - { + if (main->versionfile < 260){ { /* set default alpha value of Image outputs in image and render layer nodes to 0 */ Scene *sce; @@ -12221,6 +12223,31 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + + } + + if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 1)){ + Object *ob; + + for (ob= main->object.first; ob; ob= ob->id.next) { + ob->collision_boundtype= ob->boundtype; + } + + { + Camera *cam; + for(cam= main->camera.first; cam; cam= cam->id.next) { + if (cam->sensor_x < 0.01) + cam->sensor_x = DEFAULT_SENSOR_WIDTH; + + if (cam->sensor_y < 0.01) + cam->sensor_y = DEFAULT_SENSOR_HEIGHT; + } + } + } + + /* put compatibility code here until next subversion bump */ + { + } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/collada/CameraExporter.cpp b/source/blender/collada/CameraExporter.cpp index 6fa2c8763e0..fcb98cc7c32 100644 --- a/source/blender/collada/CameraExporter.cpp +++ b/source/blender/collada/CameraExporter.cpp @@ -71,7 +71,7 @@ void CamerasExporter::operator()(Object *ob, Scene *sce) if (cam->type == CAM_PERSP) { COLLADASW::PerspectiveOptic persp(mSW); - persp.setXFov(RAD2DEGF(lens_to_angle(cam->lens)), "xfov"); + persp.setXFov(RAD2DEGF(focallength_to_fov(cam->lens, cam->sensor_x)), "xfov"); persp.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch),false,"aspect_ratio"); persp.setZFar(cam->clipend, false , "zfar"); persp.setZNear(cam->clipsta,false , "znear"); diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 8d133979fa4..267aa925c74 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -54,7 +54,9 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BKE_camera.h" #include "BKE_main.h" +#include "BKE_lamp.h" #include "BKE_library.h" #include "BKE_texture.h" #include "BKE_fcurve.h" @@ -814,7 +816,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) double aspect = camera->getAspectRatio().getValue(); double xfov = aspect*yfov; // xfov is in degrees, cam->lens is in millimiters - cam->lens = angle_to_lens(DEG2RADF(xfov)); + cam->lens = fov_to_focallength(DEG2RADF(xfov), cam->sensor_x); } break; } @@ -835,7 +837,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) { double x = camera->getXFov().getValue(); // x is in degrees, cam->lens is in millimiters - cam->lens = angle_to_lens(DEG2RADF(x)); + cam->lens = fov_to_focallength(DEG2RADF(x), cam->sensor_x); } break; } @@ -852,7 +854,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) { double yfov = camera->getYFov().getValue(); // yfov is in degrees, cam->lens is in millimiters - cam->lens = angle_to_lens(DEG2RADF(yfov)); + cam->lens = fov_to_focallength(DEG2RADF(yfov), cam->sensor_x); } break; } diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 2774bd2cda4..569125e1055 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -237,28 +237,6 @@ void ANIM_draw_cfra (const bContext *C, View2D *v2d, short flag) glVertex2fv(vec); glEnd(); - /* Draw dark green line if slow-parenting/time-offset is enabled */ - if (flag & DRAWCFRA_SHOW_TIMEOFS) { - Object *ob= OBACT; - if(ob) { - float timeoffset= give_timeoffset(ob); - // XXX ob->ipoflag is depreceated! - if ((ob->ipoflag & OB_OFFS_OB) && (timeoffset != 0.0f)) { - vec[0]-= timeoffset; /* could avoid calling twice */ - - UI_ThemeColorShade(TH_CFRAME, -30); - - glBegin(GL_LINE_STRIP); - /*vec[1]= v2d->cur.ymax;*/ // this is set already. this line is only included - glVertex2fv(vec); - - vec[1]= v2d->cur.ymin; - glVertex2fv(vec); - glEnd(); - } - } - } - glLineWidth(1.0); /* Draw current frame number in a little box */ diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 4a359acabd9..aa1af231afd 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1069,6 +1069,8 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } +#else + (void)camera; #endif WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); @@ -1493,6 +1495,8 @@ void ED_marker_keymap(wmKeyConfig *keyconf) kmi= WM_keymap_add_item(keymap, "MARKER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "extend", 1); RNA_boolean_set(kmi->ptr, "camera", 1); +#else + (void)kmi; #endif WM_keymap_verify_item(keymap, "MARKER_OT_select_border", BKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index fb34245d338..9f466ef52d3 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -911,20 +911,6 @@ short insert_keyframe (ReportList *reports, ID *id, bAction *act, const char gro /* apply NLA-mapping to frame to use (if applicable) */ cfra= BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); } - -#if 0 - /* apply special time tweaking */ - // XXX check on this stuff... - if (GS(id->name) == ID_OB) { - //Object *ob= (Object *)id; - - /* ancient time-offset cruft */ - //if ( (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)) ) { - // /* actually frametofloat calc again! */ - // cfra-= give_timeoffset(ob)*scene->r.framelen; - //} - } -#endif /* key entire array convenience method */ if (array_index == -1) { @@ -1018,20 +1004,6 @@ short delete_keyframe (ReportList *reports, ID *id, bAction *act, const char gro } } -#if 0 - /* apply special time tweaking */ - // XXX check on this stuff... - if (GS(id->name) == ID_OB) { - //Object *ob= (Object *)id; - - /* ancient time-offset cruft */ - //if ( (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)) ) { - // /* actually frametofloat calc again! */ - // cfra-= give_timeoffset(ob)*scene->r.framelen; - //} - } -#endif - /* key entire array convenience method */ if (array_index == -1) { array_index= 0; diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 47123b7fb4d..87254c20c0f 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -173,7 +173,7 @@ void poseAnim_mapping_refresh(struct bContext *C, struct Scene *scene, struct Ob void poseAnim_mapping_reset(ListBase *pfLinks); void poseAnim_mapping_autoKeyframe(struct bContext *C, struct Scene *scene, struct Object *ob, ListBase *pfLinks, float cframe); -LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, char *path); +LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, const char *path); /* ******************************************************* */ /* PoseLib */ @@ -209,13 +209,13 @@ void BIF_sk_selectStroke(struct bContext *C, const int mval[2], short extend); /* duplicate method */ void preEditBoneDuplicate(struct ListBase *editbones); -struct EditBone *duplicateEditBone(struct EditBone *curBone, char *name, struct ListBase *editbones, struct Object *ob); +struct EditBone *duplicateEditBone(struct EditBone *curBone, const char *name, struct ListBase *editbones, struct Object *ob); void updateDuplicateSubtarget(struct EditBone *dupBone, struct ListBase *editbones, struct Object *ob); /* duplicate method (cross objects */ /* editbones is the target list */ -struct EditBone *duplicateEditBoneObjects(struct EditBone *curBone, char *name, struct ListBase *editbones, struct Object *src_ob, struct Object *dst_ob); +struct EditBone *duplicateEditBoneObjects(struct EditBone *curBone, const char *name, struct ListBase *editbones, struct Object *src_ob, struct Object *dst_ob); /* editbones is the source list */ void updateDuplicateSubtargetObjects(struct EditBone *dupBone, struct ListBase *editbones, struct Object *src_ob, struct Object *dst_ob); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index d9482ebe292..a8b3ee462ae 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -2523,7 +2523,7 @@ void updateDuplicateSubtarget(EditBone *dupBone, ListBase *editbones, Object *ob } -EditBone *duplicateEditBoneObjects(EditBone *curBone, char *name, ListBase *editbones, Object *src_ob, Object *dst_ob) +EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase *editbones, Object *src_ob, Object *dst_ob) { EditBone *eBone = MEM_mallocN(sizeof(EditBone), "addup_editbone"); @@ -2567,7 +2567,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, char *name, ListBase *edit return eBone; } -EditBone *duplicateEditBone(EditBone *curBone, char *name, ListBase *editbones, Object *ob) +EditBone *duplicateEditBone(EditBone *curBone, const char *name, ListBase *editbones, Object *ob) { return duplicateEditBoneObjects(curBone, name, editbones, ob, ob); } @@ -5319,7 +5319,7 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldnam /* called by UI for renaming a bone */ /* warning: make sure the original bone was not renamed yet! */ /* seems messy, but thats what you get with not using pointers but channel names :) */ -void ED_armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep) +void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *newnamep) { Object *ob; char newname[MAXBONENAME]; diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 31be1efdc1f..d228d4d3772 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -187,7 +187,7 @@ void BIF_makeListTemplates(const bContext *C) } } -char *BIF_listTemplates(const bContext *UNUSED(C)) +const char *BIF_listTemplates(const bContext *UNUSED(C)) { GHashIterator ghi; char menu_header[] = "Template%t|None%x0|"; diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c index 71cdda7fe15..1a9ff73e5dc 100644 --- a/source/blender/editors/armature/poseUtils.c +++ b/source/blender/editors/armature/poseUtils.c @@ -262,7 +262,7 @@ void poseAnim_mapping_autoKeyframe (bContext *C, Scene *scene, Object *ob, ListB /* find the next F-Curve for a PoseChannel with matching path... * - path is not just the pfl rna_path, since that path doesn't have property info yet */ -LinkData *poseAnim_mapping_getNextFCurve (ListBase *fcuLinks, LinkData *prev, char *path) +LinkData *poseAnim_mapping_getNextFCurve (ListBase *fcuLinks, LinkData *prev, const char *path) { LinkData *first= (prev)? prev->next : (fcuLinks)? fcuLinks->first : NULL; LinkData *ld; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 4f6519bad5b..c010ce7fbf7 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -2812,12 +2812,7 @@ void CURVE_OT_select_inverse(wmOperatorType *ot) /** Divide the line segments associated with the currently selected * curve nodes (Bezier or NURB). If there are no valid segment * selections within the current selection, nothing happens. - * - * @deffunc subdividenurb subdivideNurb(void) - * @return Nothing - * @param None -*/ - + */ static void subdividenurb(Object *obedit, int number_cuts) { Curve *cu= obedit->data; diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index c915bc9ea37..d481be94bcc 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -183,7 +183,10 @@ static int gp_data_add_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else { - /* just add new datablock now */ + /* decrement user count and add new datablock */ + bGPdata *gpd= (*gpd_ptr); + + id_us_min(&gpd->id); *gpd_ptr= gpencil_data_addnew("GPencil"); } @@ -231,7 +234,7 @@ static int gp_data_unlink_exec (bContext *C, wmOperator *op) /* just unlink datablock now, decreasing its user count */ bGPdata *gpd= (*gpd_ptr); - gpd->id.us--; + id_us_min(&gpd->id); *gpd_ptr= NULL; } diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 0ac5a9e46ce..6b449f68e1d 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -462,10 +462,8 @@ enum { DRAWCFRA_SHOW_NUMBOX = (1<<0), /* time indication in seconds or frames */ DRAWCFRA_UNIT_SECONDS = (1<<1), - /* show time-offset line */ - DRAWCFRA_SHOW_TIMEOFS = (1<<2), /* draw indicator extra wide (for timeline) */ - DRAWCFRA_WIDE = (1<<3) + DRAWCFRA_WIDE = (1<<2) } eAnimEditDraw_CurrentFrame; /* main call to draw current-frame indicator in an Animation Editor */ diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 121c53f7c65..2e9186b6c2f 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -141,7 +141,7 @@ void create_vgroups_from_armature(struct ReportList *reports, struct Scene *scen void auto_align_armature(struct Scene *scene, struct View3D *v3d, short mode); void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone); /* if bone is already in list, pass it as param to ignore it */ -void ED_armature_bone_rename(struct bArmature *arm, char *oldnamep, char *newnamep); +void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const char *newnamep); void undo_push_armature(struct bContext *C, const char *name); @@ -163,7 +163,7 @@ void BIF_deleteSketch(struct bContext *C); void BIF_selectAllSketch(struct bContext *C, int mode); /* -1: deselect, 0: select, 1: toggle */ void BIF_makeListTemplates(const struct bContext *C); -char *BIF_listTemplates(const struct bContext *C); +const char *BIF_listTemplates(const struct bContext *C); int BIF_currentTemplate(const struct bContext *C); void BIF_freeTemplates(struct bContext *C); void BIF_setTemplate(struct bContext *C, int index); diff --git a/source/blender/editors/include/ED_fluidsim.h b/source/blender/editors/include/ED_fluidsim.h index f48b5df56c0..d47ba2bfba9 100644 --- a/source/blender/editors/include/ED_fluidsim.h +++ b/source/blender/editors/include/ED_fluidsim.h @@ -48,9 +48,4 @@ void fluidsimSettingsFree(struct FluidsimSettings* sb); /* duplicate internal data */ struct FluidsimSettings* fluidsimSettingsCopy(struct FluidsimSettings* sb); -/* memory estimate */ -void fluidsimEstimateMemory(struct Object *ob, struct FluidsimSettings *fs, char *value); - #endif /* ED_FLUIDSIM_H */ - - diff --git a/source/blender/editors/include/ED_logic.h b/source/blender/editors/include/ED_logic.h index e6026eb5fee..ce1f2b8faac 100644 --- a/source/blender/editors/include/ED_logic.h +++ b/source/blender/editors/include/ED_logic.h @@ -34,6 +34,3 @@ void ED_operatortypes_logic(void); #endif /* ED_LOGIC_H */ - - - diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index 48232acf562..d1da9f308fb 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -72,7 +72,7 @@ void PE_undo(struct Scene *scene); void PE_redo(struct Scene *scene); int PE_undo_valid(struct Scene *scene); void PE_undo_number(struct Scene *scene, int nr); -char *PE_undo_get_name(struct Scene *scene, int nr, int *active); +const char *PE_undo_get_name(struct Scene *scene, int nr, int *active); #endif /* ED_PARTICLE_H */ diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index c644b1d27b4..3a6cbc556d1 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -107,10 +107,12 @@ struct Base; struct Scene; struct Object; +#if 0 /* UNUSED, deprecate? */ void BIF_setSingleAxisConstraint(float vec[3], char *text); void BIF_setDualAxisConstraint(float vec1[3], float vec2[3], char *text); void BIF_setLocalAxisConstraint(char axis, char *text); void BIF_setLocalLockConstraint(char axis, char *text); +#endif int BIF_snappingSupported(struct Object *obedit); @@ -132,7 +134,7 @@ struct EnumPropertyItem *BIF_enumTransformOrientation(struct bContext *C); const char * BIF_menustringTransformOrientation(const struct bContext *C, const char *title); /* the returned value was allocated and needs to be freed after use */ int BIF_countTransformOrientation(const struct bContext *C); -void BIF_TransformSetUndo(char *str); +void BIF_TransformSetUndo(const char *str); void BIF_selectOrientation(void); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 884992d8765..aa2ee6adc72 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -133,7 +133,6 @@ void ED_view3d_win_to_segment_clip(struct ARegion *ar, struct View3D *v3d, const * 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. @@ -143,7 +142,7 @@ void ED_view3d_win_to_ray(struct ARegion *ar, struct View3D *v3d, const float mv /** * 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 rv3d The region (used for the window width and height). * @param coord The world-space location. * @param vec The resulting normalized vector. */ @@ -174,6 +173,7 @@ void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist) * @param ofs The view offset to be set, normally from RegionView3D.ofs. * @param quat The view rotation to be set, quaternion normally from RegionView3D.viewquat. * @param dist The view distance from ofs to be set, normally from RegionView3D.dist. + * @param lens The view lens angle set for cameras and lamps, normally from View3D.lens. */ void ED_view3d_from_object(struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index cb18ea37ffc..7a556eddd2b 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -506,8 +506,6 @@ uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x1, i uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x1, int y1, short x2, short y2, float a1, float a2, const char *tip); -void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval); - uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2); int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, int (*check_prop)(struct PropertyRNA *), const char label_align); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index a6316dc0e9e..dd75f506be8 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -766,7 +766,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) { uiBut *but; - unsigned int meny_key_mask= 0; + unsigned int menu_key_mask= 0; unsigned char menu_key; const char *str_pt; int pass; @@ -788,8 +788,8 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) if(but->str) { for(str_pt= but->str; *str_pt; ) { menu_key= tolower(*str_pt); - if((menu_key >= 'a' && menu_key <= 'z') && !(meny_key_mask & 1<<(menu_key-'a'))) { - meny_key_mask |= 1<<(menu_key-'a'); + if((menu_key >= 'a' && menu_key <= 'z') && !(menu_key_mask & 1<<(menu_key-'a'))) { + menu_key_mask |= 1<<(menu_key-'a'); break; } @@ -816,7 +816,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) } /* if all keys have been used just exit, unlikely */ - if(meny_key_mask == (1<<26)-1) { + if(menu_key_mask == (1<<26)-1) { return; } } @@ -2569,10 +2569,12 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, if(block->curlayout) ui_layout_add_but(block->curlayout, but); +#ifdef WITH_PYTHON /* if the 'UI_OT_editsource' is running, extract the source info from the button */ if (UI_editsource_enable_check()) { UI_editsource_active_but_test(but); } +#endif return but; } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index e49cb4898d9..0ba141163b3 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3216,6 +3216,63 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, return changed; } +static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOFMotionData *ndof, int shift) +{ + float *hsv= ui_block_hsv_get(but->block); + float rgb[3]; + float sensitivity = (shift?0.15:0.3) * ndof->dt; + + int color_profile = but->block->color_profile; + + if (but->rnaprop) { + if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) + color_profile = BLI_PR_NONE; + } + + ui_get_but_vectorf(but, rgb); + rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); + + switch((int)but->a1) { + case UI_GRAD_SV: + hsv[2] += ndof->ry * sensitivity; + hsv[1] += ndof->rx * sensitivity; + break; + case UI_GRAD_HV: + hsv[0] += ndof->ry * sensitivity; + hsv[2] += ndof->rx * sensitivity; + break; + case UI_GRAD_HS: + hsv[0] += ndof->ry * sensitivity; + hsv[1] += ndof->rx * sensitivity; + break; + case UI_GRAD_H: + hsv[0] += ndof->ry * sensitivity; + break; + case UI_GRAD_S: + hsv[1] += ndof->ry * sensitivity; + break; + case UI_GRAD_V: + hsv[2] += ndof->ry * sensitivity; + break; + case UI_GRAD_V_ALT: + /* vertical 'value' strip */ + + /* exception only for value strip - use the range set in but->min/max */ + hsv[2] += ndof->rx * sensitivity; + + if (color_profile) + hsv[2] = srgb_to_linearrgb(hsv[2]); + + CLAMP(hsv[2], but->softmin, but->softmax); + default: + assert(!"invalid hsv type"); + } + + hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); + copy_v3_v3(data->vec, rgb); + ui_set_but_vectorf(but, data->vec); +} + static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) { int mx, my; @@ -3238,8 +3295,18 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu return WM_UI_HANDLER_BREAK; } + else if (event->type == NDOF_MOTION) { + wmNDOFMotionData *ndof = (wmNDOFMotionData*) event->customdata; + + ui_ndofedit_but_HSVCUBE(but, data, ndof, event->shift); + + button_activate_state(C, but, BUTTON_STATE_EXIT); + ui_apply_button(C, but->block, but, data, 1); + + return WM_UI_HANDLER_BREAK; + } /* XXX hardcoded keymap check.... */ - else if (ELEM(event->type, ZEROKEY, PAD0) && event->val == KM_PRESS) { + else if (event->type == DELKEY && event->val == KM_PRESS) { if (but->a1==UI_GRAD_V_ALT){ int len; @@ -3337,11 +3404,62 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx return changed; } +static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmNDOFMotionData *ndof, int shift) +{ + float *hsv= ui_block_hsv_get(but->block); + float rgb[3]; + float phi, r /*, sqr */ /* UNUSED */, v[2]; + float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt; + + ui_get_but_vectorf(but, rgb); + rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); + + /* Convert current colour on hue/sat disc to circular coordinates phi, r */ + phi = fmodf(hsv[0]+0.25f, 1.0f) * -2.0f*M_PI; + r = hsv[1]; + /* sqr= r>0.f?sqrtf(r):1; */ /* UNUSED */ + + /* Convert to 2d vectors */ + v[0] = r * cosf(phi); + v[1] = r * sinf(phi); + + /* Use ndof device y and x rotation to move the vector in 2d space */ + v[0] += ndof->ry * sensitivity; + v[1] += ndof->rx * sensitivity; + + /* convert back to polar coords on circle */ + phi = atan2(v[0], v[1])/(2.0f*(float)M_PI) + 0.5f; + + /* use ndof z rotation to additionally rotate hue */ + phi -= ndof->rz * sensitivity * 0.5f; + + r = len_v2(v); + CLAMP(r, 0.0f, 1.0f); + + /* convert back to hsv values, in range [0,1] */ + hsv[0] = fmodf(phi, 1.0f); + hsv[1] = r; + + /* exception, when using color wheel in 'locked' value state: + * allow choosing a hue for black values, by giving a tiny increment */ + if (but->flag & UI_BUT_COLOR_LOCK) { // lock + if (hsv[2] == 0.0f) hsv[2] = 0.0001f; + } + + hsv_to_rgb(hsv[0], hsv[1], hsv[2], data->vec, data->vec+1, data->vec+2); + + if((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) { + normalize_v3(data->vec); + mul_v3_fl(data->vec, but->a2); + } + + ui_set_but_vectorf(but, data->vec); +} + static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) { int mx, my; - mx= event->x; my= event->y; ui_window_to_block(data->region, block, &mx, &my); @@ -3360,8 +3478,18 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle return WM_UI_HANDLER_BREAK; } + else if (event->type == NDOF_MOTION) { + wmNDOFMotionData *ndof = (wmNDOFMotionData*) event->customdata; + + ui_ndofedit_but_HSVCIRCLE(but, data, ndof, event->shift); + + button_activate_state(C, but, BUTTON_STATE_EXIT); + ui_apply_button(C, but->block, but, data, 1); + + return WM_UI_HANDLER_BREAK; + } /* XXX hardcoded keymap check.... */ - else if (ELEM(event->type, ZEROKEY, PAD0) && event->val == KM_PRESS) { + else if (event->type == DELKEY && event->val == KM_PRESS) { int len; /* reset only saturation */ @@ -3810,7 +3938,7 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle return WM_UI_HANDLER_BREAK; } /* XXX hardcoded keymap check.... */ - else if (ELEM(event->type, ZEROKEY, PAD0) && event->val == KM_PRESS) { + else if (event->type == DELKEY && event->val == KM_PRESS) { Histogram *hist = (Histogram *)but->poin; hist->ymax = 1.f; @@ -3893,7 +4021,7 @@ static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleB return WM_UI_HANDLER_BREAK; } /* XXX hardcoded keymap check.... */ - else if (ELEM(event->type, ZEROKEY, PAD0) && event->val == KM_PRESS) { + else if (event->type == DELKEY && event->val == KM_PRESS) { Scopes *scopes = (Scopes *)but->poin; scopes->wavefrm_yfac = 1.f; diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 27f94ae8e49..5803054caa7 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -43,6 +43,7 @@ #include "BLI_utildefines.h" #include "BKE_context.h" +#include "BKE_screen.h" #include "BKE_global.h" #include "BKE_text.h" /* for UI_OT_reports_to_text */ #include "BKE_report.h" @@ -476,6 +477,7 @@ static void UI_OT_reports_to_textblock(wmOperatorType *ot) ot->exec= reports_to_text_exec; } +#ifdef WITH_PYTHON /* ------------------------------------------------------------------------- */ /* EditSource Utility funcs and operator, @@ -576,24 +578,6 @@ void UI_editsource_active_but_test(uiBut *but) /* editsource operator component */ -static ScrArea *biggest_text_view(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) { - if(sa->spacetype==SPACE_TEXT) { - size= sa->winx * sa->winy; - if(size > maxsize) { - maxsize= size; - big= sa; - } - } - } - return big; -} - static int editsource_text_edit(bContext *C, wmOperator *op, char filepath[240], int line) { @@ -618,7 +602,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op, else { /* naughty!, find text area to set, not good behavior * but since this is a dev tool lets allow it - campbell */ - ScrArea *sa= biggest_text_view(C); + ScrArea *sa= BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0); if(sa) { SpaceText *st= sa->spacedata.first; st->text= text; @@ -711,6 +695,7 @@ static void UI_OT_editsource(wmOperatorType *ot) ot->exec= editsource_exec; } +#endif /* WITH_PYTHON */ /* ********************************************************* */ /* Registration */ @@ -723,6 +708,9 @@ void UI_buttons_operatortypes(void) WM_operatortype_append(UI_OT_reset_default_button); WM_operatortype_append(UI_OT_copy_to_selected_button); WM_operatortype_append(UI_OT_reports_to_textblock); // XXX: temp? + +#ifdef WITH_PYTHON WM_operatortype_append(UI_OT_editsource); +#endif } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 3067059c448..b135aae30d5 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -54,6 +54,7 @@ #include "BKE_anim.h" #include "BKE_animsys.h" #include "BKE_armature.h" +#include "BKE_camera.h" #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_curve.h" @@ -62,6 +63,7 @@ #include "BKE_displist.h" #include "BKE_effect.h" #include "BKE_group.h" +#include "BKE_lamp.h" #include "BKE_lattice.h" #include "BKE_library.h" #include "BKE_key.h" diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 251a86cf996..9dbbb1b8b0a 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -54,6 +54,7 @@ #include "BLI_math_geom.h" #include "BKE_blender.h" +#include "BKE_screen.h" #include "BKE_context.h" #include "BKE_global.h" #include "BKE_image.h" @@ -1246,24 +1247,6 @@ static int thread_break(void *UNUSED(arg)) return G.afbreek; } -static ScrArea *biggest_image_area(bScreen *screen) -{ - ScrArea *sa, *big= NULL; - int size, maxsize= 0; - - for(sa= screen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_IMAGE) { - size= sa->winx*sa->winy; - if(sa->winx > 10 && sa->winy > 10 && size > maxsize) { - maxsize= size; - big= sa; - } - } - } - return big; -} - - typedef struct BakeRender { Render *re; Main *main; @@ -1314,7 +1297,7 @@ static void init_bake_internal(BakeRender *bkr, bContext *C) /* get editmode results */ ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ - bkr->sa= biggest_image_area(CTX_wm_screen(C)); /* can be NULL */ + bkr->sa= BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_IMAGE, 10); /* can be NULL */ bkr->main= CTX_data_main(C); bkr->scene= scene; bkr->actob= (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT : NULL; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index fa2076457a0..1c94ba1afbb 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1183,7 +1183,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) base->object->min_vel= ob->min_vel; base->object->max_vel= ob->max_vel; if (ob->gameflag & OB_BOUNDS) { - base->object->boundtype = ob->boundtype; + base->object->collision_boundtype = ob->collision_boundtype; } base->object->margin= ob->margin; base->object->bsoft= copy_bulletsoftbody(ob->bsoft); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 84d92318a8f..ae6ec15e911 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -56,6 +56,7 @@ #include "BKE_action.h" #include "BKE_animsys.h" #include "BKE_armature.h" +#include "BKE_camera.h" #include "BKE_context.h" #include "BKE_constraint.h" #include "BKE_curve.h" @@ -63,6 +64,7 @@ #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_fcurve.h" +#include "BKE_lamp.h" #include "BKE_lattice.h" #include "BKE_library.h" #include "BKE_main.h" @@ -651,7 +653,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) data = con->data; data->tar = par; - get_constraint_target_matrix(scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra - give_timeoffset(ob)); + get_constraint_target_matrix(scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra); sub_v3_v3v3(vec, ob->obmat[3], cmat[3]); ob->loc[0] = vec[0]; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 0d080c7ea01..d60b7b31bf4 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -646,7 +646,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) /* get the view settings if 'around' isnt set and the view is available */ View3D *v3d= CTX_wm_view3d(C); copy_v3_v3(cursor, give_cursor(scene, v3d)); - if(v3d && !RNA_property_is_set(op->ptr, "around")) + if(v3d && !RNA_property_is_set(op->ptr, "center")) around= v3d->around; } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 827360505f0..2852c57338a 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -4024,7 +4024,7 @@ void PE_undo_number(Scene *scene, int nr) /* get name of undo item, return null if no item with this index */ /* if active pointer, set it to 1 if true */ -char *PE_undo_get_name(Scene *scene, int nr, int *active) +const char *PE_undo_get_name(Scene *scene, int nr, int *active) { PTCacheEdit *edit= PE_get_current(scene, OBACT); PTCacheUndo *undo; diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 9da160948cc..feff1e05d60 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -70,6 +70,7 @@ #include "BKE_idprop.h" #include "BKE_image.h" #include "BKE_icons.h" +#include "BKE_lamp.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_material.h" diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c index 47957c0bb5a..d8719c7d7cd 100644 --- a/source/blender/editors/render/render_view.c +++ b/source/blender/editors/render/render_view.c @@ -58,6 +58,7 @@ /* returns biggest area that is not uv/image editor. Note that it uses buttons */ /* window as the last possible alternative. */ +/* would use BKE_screen_find_big_area(...) but this is too specific */ static ScrArea *biggest_non_image_area(bContext *C) { bScreen *sc= CTX_wm_screen(C); @@ -85,22 +86,6 @@ static ScrArea *biggest_non_image_area(bContext *C) 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); @@ -206,7 +191,7 @@ void render_view_open(bContext *C, int mx, int my) } else { /* use any area of decent size */ - sa= biggest_area(C); + sa= BKE_screen_find_big_area(CTX_wm_screen(C), -1, 0); if(sa->spacetype!=SPACE_IMAGE) { // XXX newspace(sa, SPACE_IMAGE); sima= sa->spacedata.first; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 7e79849ba40..9d6d663df5c 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -84,19 +84,19 @@ static void region_draw_emboss(ARegion *ar, rcti *scirct) glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); /* right */ - glColor4ub(0,0,0, 50); + glColor4ub(0,0,0, 30); sdrawline(rect.xmax, rect.ymin, rect.xmax, rect.ymax); /* bottom */ - glColor4ub(0,0,0, 80); + glColor4ub(0,0,0, 30); sdrawline(rect.xmin, rect.ymin, rect.xmax, rect.ymin); /* top */ - glColor4ub(255,255,255, 60); + glColor4ub(255,255,255, 30); sdrawline(rect.xmin, rect.ymax, rect.xmax, rect.ymax); /* left */ - glColor4ub(255,255,255, 50); + glColor4ub(255,255,255, 30); sdrawline(rect.xmin, rect.ymin, rect.xmin, rect.ymax); glDisable( GL_BLEND ); @@ -414,6 +414,9 @@ void ED_region_do_draw(bContext *C, ARegion *ar) /* note; this sets state, so we can use wmOrtho and friends */ wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct); + + ar->do_draw= 0; + memset(&ar->drawrct, 0, sizeof(ar->drawrct)); UI_SetTheme(sa?sa->spacetype:0, ar->type?ar->type->regionid:0); @@ -429,18 +432,15 @@ void ED_region_do_draw(bContext *C, ARegion *ar) at->draw(C, ar); } + /* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */ + ED_region_pixelspace(ar); + ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL); uiFreeInactiveBlocks(C, &ar->uiblocks); - + if(sa) region_draw_emboss(ar, &winrct); - - /* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */ - ED_region_pixelspace(ar); - - ar->do_draw= 0; - memset(&ar->drawrct, 0, sizeof(ar->drawrct)); } /* ********************************** diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 1d2bab1862a..bf4d081508f 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -57,6 +57,7 @@ #include "IMB_imbuf_types.h" #include "DNA_brush_types.h" +#include "DNA_camera_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_node_types.h" @@ -64,6 +65,7 @@ #include "DNA_scene_types.h" #include "DNA_texture_types.h" +#include "BKE_camera.h" #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" @@ -3003,7 +3005,8 @@ static void project_paint_begin(ProjPaintState *ps) Object *camera= ps->scene->camera; /* dont actually use these */ - float _viewdx, _viewdy, _ycor, _lens=0.0f; + float _viewdx, _viewdy, _ycor, _lens=0.0f, _sensor_x=DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT; + short _sensor_fit= CAMERA_SENSOR_FIT_AUTO; rctf _viewplane; /* viewmat & viewinv */ @@ -3015,7 +3018,7 @@ static void project_paint_begin(ProjPaintState *ps) object_camera_mode(&ps->scene->r, camera); object_camera_matrix(&ps->scene->r, camera, ps->winx, ps->winy, 0, winmat, &_viewplane, &ps->clipsta, &ps->clipend, - &_lens, &_ycor, &_viewdx, &_viewdy); + &_lens, &_sensor_x, &_sensor_y, &_sensor_fit, &_ycor, &_viewdx, &_viewdy); ps->is_ortho= (ps->scene->r.mode & R_ORTHO) ? 1 : 0; } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index e739c5fe22e..deed7ad2a3a 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -666,7 +666,7 @@ struct direntry * filelist_file(struct FileList* filelist, int index) return &filelist->filelist[fidx]; } -int filelist_find(struct FileList* filelist, char *file) +int filelist_find(struct FileList* filelist, const char *filename) { int index = -1; int i; @@ -677,7 +677,7 @@ int filelist_find(struct FileList* filelist, char *file) for (i = 0; i < filelist->numfiles; ++i) { - if ( strcmp(filelist->filelist[i].relname, file) == 0) { /* not dealing with user input so dont need BLI_path_cmp */ + if ( strcmp(filelist->filelist[i].relname, filename) == 0) { /* not dealing with user input so dont need BLI_path_cmp */ index = i; break; } diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h index a7f2a0d1af9..cd4c22df418 100644 --- a/source/blender/editors/space_file/filelist.h +++ b/source/blender/editors/space_file/filelist.h @@ -66,7 +66,7 @@ typedef enum FileCheckType struct FileList * filelist_new(short type); void filelist_init_icons(void); void filelist_free_icons(void); -int filelist_find(struct FileList* filelist, char *file); +int filelist_find(struct FileList* filelist, const char *file); void filelist_free(struct FileList* filelist); void filelist_sort(struct FileList* filelist, short sort); int filelist_numfiles(struct FileList* filelist); diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 37e6c0b73c9..7091fe094c6 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -78,11 +78,11 @@ * - intV: integer value containing color info packed into an int * - alpha: float value describing the */ -#define cpackA(intVC, alpha) \ - { \ - float _cpackCol[3]; \ - cpack_to_rgb(intVC, &_cpackCol[0], &_cpackCol[1], &_cpackCol[2]); \ - glColor4f(_cpackCol[0], _cpackCol[1], _cpackCol[2], alpha); \ +#define cpackA(intVC, alpha) \ + { \ + float _cpackCol[3]; \ + cpack_to_rgb(intVC, &_cpackCol[0], &_cpackCol[1], &_cpackCol[2]); \ + glColor4f(_cpackCol[0], _cpackCol[1], _cpackCol[2], alpha); \ } /* *************************** */ diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 505452f504c..77ac577792c 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -127,7 +127,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar) BKE_image_release_renderresult(scene, ima); } -void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf) +void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y, const char cp[4], const float fp[4], int *zp, float *zpf) { char str[256]; float dx= 6; diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index 4310b5dbae8..04156c80c0e 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -55,7 +55,7 @@ void IMAGE_OT_toolbox(struct wmOperatorType *ot); /* image_draw.c */ void draw_image_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene); -void draw_image_info(struct ARegion *ar, int color_manage, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf); +void draw_image_info(struct ARegion *ar, int color_manage, int channels, int x, int y, const char cp[4], const float fp[4], int *zp, float *zpf); void draw_image_grease_pencil(struct bContext *C, short onlyv2d); /* image_ops.c */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 7a9cf644b55..24ea51567ad 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -842,6 +842,11 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN } } +void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr) +{ + uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL); +} + static void node_common_buts_whileloop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "max_iterations", 0, NULL, 0); @@ -867,7 +872,7 @@ static void node_common_set_butfunc(bNodeType *ntype) { switch(ntype->type) { case NODE_GROUP: -// ntype->uifunc= node_common_buts_group; + ntype->uifunc= node_uifunc_group; ntype->drawfunc= node_draw_group; ntype->drawupdatefunc= node_update_group; break; @@ -2119,7 +2124,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) } } -void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int x, int y, char *cp, float *fp) +void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int x, int y, const char cp[4], const float fp[4]) { char str[256]; float dx= 6; diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 655d54ac8a7..88b81d0855c 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -99,7 +99,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int t int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol); void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 ); void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage); -void draw_nodespace_color_info(struct ARegion *ar, int color_manage, int channels, int x, int y, char *cp, float *fp); +void draw_nodespace_color_info(struct ARegion *ar, int color_manage, int channels, int x, int y, const char cp[4], const float fp[4]); /* node_edit.c */ void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index cd8739559a1..920494dcec2 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -56,6 +56,7 @@ #include "BLI_utildefines.h" #include "BKE_anim.h" //for the where_on_path function +#include "BKE_camera.h" #include "BKE_constraint.h" // for the get_constraint_target function #include "BKE_curve.h" #include "BKE_DerivedMesh.h" @@ -74,6 +75,7 @@ #include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_pointcache.h" +#include "BKE_scene.h" #include "BKE_unit.h" #include "BKE_tessmesh.h" @@ -106,11 +108,11 @@ /* this condition has been made more complex since editmode can draw textures */ -#define CHECK_OB_DRAWTEXTURE(vd, dt) \ - ((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || \ +#define CHECK_OB_DRAWTEXTURE(vd, dt) \ + ((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || \ (vd->drawtype==OB_SOLID && vd->flag2 & V3D_SOLID_TEX)) -static void draw_bounding_volume(Scene *scene, Object *ob); +static void draw_bounding_volume(Scene *scene, Object *ob, char type); static void drawcube_size(float size); static void drawcircle_size(float size); @@ -2786,7 +2788,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D if(dt==OB_BOUNDBOX) { if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0) - draw_bounding_volume(scene, ob); + draw_bounding_volume(scene, ob, ob->boundtype); } else if(hasHaloMat || (totface==0 && totedge==0)) { glPointSize(1.5); @@ -3754,7 +3756,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv totpart=psys->totpart; - cfra= bsystem_time(scene, NULL, (float)CFRA, 0.0f); + cfra= BKE_curframe(scene); if(draw_as==PART_DRAW_PATH && psys->pathcache==NULL && psys->childcache==NULL) draw_as=PART_DRAW_DOT; @@ -5552,7 +5554,7 @@ static void get_local_bounds(Object *ob, float center[3], float size[3]) } #endif -static void draw_bb_quadric(BoundBox *bb, short type) +static void draw_bb_quadric(BoundBox *bb, char type) { float size[3], cent[3]; GLUquadricObj *qobj = gluNewQuadric(); @@ -5591,7 +5593,7 @@ static void draw_bb_quadric(BoundBox *bb, short type) gluDeleteQuadric(qobj); } -static void draw_bounding_volume(Scene *scene, Object *ob) +static void draw_bounding_volume(Scene *scene, Object *ob, char type) { BoundBox *bb= NULL; @@ -5617,8 +5619,8 @@ static void draw_bounding_volume(Scene *scene, Object *ob) if(bb==NULL) return; - if(ob->boundtype==OB_BOUND_BOX) draw_box(bb->vec); - else draw_bb_quadric(bb, ob->boundtype); + if(type==OB_BOUND_BOX) draw_box(bb->vec); + else draw_bb_quadric(bb, type); } @@ -5830,7 +5832,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) Object *ob; Curve *cu; RegionView3D *rv3d= ar->regiondata; - //float cfraont; float vec1[3], vec2[3]; unsigned int col=0; int /*sel, drawtype,*/ colindex= 0; @@ -5869,83 +5870,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* no return after this point, otherwise leaks */ view3d_cached_text_draw_begin(); - - /* draw keys? */ -#if 0 // XXX old animation system - if(base==(scene->basact) || (base->flag & (SELECT+BA_WAS_SEL))) { - if(flag==0 && warning_recursive==0 && ob!=scene->obedit) { - if(ob->ipo && ob->ipo->showkey && (ob->ipoflag & OB_DRAWKEY)) { - ListBase elems; - CfraElem *ce; - float temp[7][3]; - - warning_recursive= 1; - - elems.first= elems.last= 0; - // warning: no longer checks for certain ob-keys only... (so does this need to use the proper ipokeys then?) - make_cfra_list(ob->ipo, &elems); - - cfraont= (scene->r.cfra); - drawtype= v3d->drawtype; - if(drawtype>OB_WIRE) v3d->drawtype= OB_WIRE; - sel= base->flag; - memcpy(temp, &ob->loc, 7*3*sizeof(float)); - - ipoflag= ob->ipoflag; - ob->ipoflag &= ~OB_OFFS_OB; - - set_no_parent_ipo(1); - disable_speed_curve(1); - - if ((ob->ipoflag & OB_DRAWKEYSEL)==0) { - ce= elems.first; - while(ce) { - if(!ce->sel) { - (scene->r.cfra)= ce->cfra/scene->r.framelen; - - base->flag= 0; - - where_is_object_time(scene, ob, (scene->r.cfra)); - draw_object(scene, ar, v3d, base, 0); - } - ce= ce->next; - } - } - - ce= elems.first; - while(ce) { - if(ce->sel) { - (scene->r.cfra)= ce->cfra/scene->r.framelen; - - base->flag= SELECT; - - where_is_object_time(scene, ob, (scene->r.cfra)); - draw_object(scene, ar, v3d, base, 0); - } - ce= ce->next; - } - - set_no_parent_ipo(0); - disable_speed_curve(0); - - base->flag= sel; - ob->ipoflag= ipoflag; - - /* restore icu->curval */ - (scene->r.cfra)= cfraont; - - memcpy(&ob->loc, temp, 7*3*sizeof(float)); - where_is_object(scene, ob); - v3d->drawtype= drawtype; - - BLI_freelistN(&elems); - - warning_recursive= 0; - } - } - } -#endif // XXX old animation system - /* patch? children objects with a timeoffs change the parents. How to solve! */ /* if( ((int)ob->ctime) != F_(scene->r.cfra)) where_is_object(scene, ob); */ @@ -6003,7 +5927,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(base->flag & (SELECT+BA_WAS_SEL)) { /* uses darker active color for non-active + selected*/ theme_id= TH_GROUP_ACTIVE; - + if(scene->basact != base) { theme_shade= -16; } @@ -6184,7 +6108,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } else if(dt==OB_BOUNDBOX) { if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0) - draw_bounding_volume(scene, ob); + draw_bounding_volume(scene, ob, ob->boundtype); } else if(ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) empty_object= drawDispList(scene, v3d, rv3d, base, dt); @@ -6200,7 +6124,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } else if(dt==OB_BOUNDBOX) { if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0) - draw_bounding_volume(scene, ob); + draw_bounding_volume(scene, ob, ob->boundtype); } else if(ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { empty_object= drawDispList(scene, v3d, rv3d, base, dt); @@ -6217,7 +6141,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) drawmball(scene, v3d, rv3d, base, dt); else if(dt==OB_BOUNDBOX) { if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0) - draw_bounding_volume(scene, ob); + draw_bounding_volume(scene, ob, ob->boundtype); } else empty_object= drawmball(scene, v3d, rv3d, base, dt); @@ -6459,6 +6383,14 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } } + if(ob->gameflag & OB_BOUNDS) { + if(ob->boundtype!=ob->collision_boundtype || (dtx & OB_BOUNDBOX)==0) { + setlinestyle(2); + draw_bounding_volume(scene, ob, ob->collision_boundtype); + setlinestyle(0); + } + } + /* draw extra: after normal draw because of makeDispList */ if(dtx && (G.f & G_RENDER_OGL)==0) { @@ -6466,8 +6398,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) drawaxes(1.0f, OB_ARROWS); } if(dtx & OB_BOUNDBOX) { - if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) - draw_bounding_volume(scene, ob); + draw_bounding_volume(scene, ob, ob->boundtype); } if(dtx & OB_TEXSPACE) drawtexspace(ob); if(dtx & OB_DRAWNAME) { @@ -6585,7 +6516,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) for (ct= targets.first; ct; ct= ct->next) { /* calculate target's matrix */ if (cti->get_target_matrix) - cti->get_target_matrix(curcon, cob, ct, bsystem_time(scene, ob, (float)(scene->r.cfra), give_timeoffset(ob))); + cti->get_target_matrix(curcon, cob, ct, BKE_curframe(scene)); else unit_m4(ct->matrix); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 04acc7e9b4d..faf4e9412be 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -875,6 +875,7 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn) case ND_MODE: case ND_LAYER: case ND_LAYER_CONTENT: + case ND_TOOLSETTINGS: ED_region_tag_redraw(ar); break; } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 96031a7b3d3..309578699f7 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -51,6 +51,7 @@ #include "BLI_utildefines.h" #include "BKE_anim.h" +#include "BKE_camera.h" #include "BKE_context.h" #include "BKE_customdata.h" #include "BKE_image.h" @@ -921,17 +922,34 @@ static void draw_selected_name(Scene *scene, Object *ob) BLF_draw_default(offset, 10, 0.0f, info, sizeof(info)-1); } -void view3d_viewborder_size_get(Scene *scene, ARegion *ar, float size_r[2]) +void view3d_viewborder_size_get(Scene *scene, Object *camob, ARegion *ar, float size_r[2]) { - float winmax= MAX2(ar->winx, ar->winy); float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp); - - if(aspect > 1.0f) { - size_r[0]= winmax; - size_r[1]= winmax/aspect; - } else { - size_r[0]= winmax*aspect; - size_r[1]= winmax; + short sensor_fit= CAMERA_SENSOR_FIT_AUTO; + + if(camob && camob->type==OB_CAMERA) { + Camera *cam= (Camera *)camob->data; + sensor_fit= cam->sensor_fit; + } + + if(sensor_fit==CAMERA_SENSOR_FIT_AUTO) { + float winmax= MAX2(ar->winx, ar->winy); + + if(aspect > 1.0f) { + size_r[0]= winmax; + size_r[1]= winmax/aspect; + } else { + size_r[0]= winmax*aspect; + size_r[1]= winmax; + } + } + else if(sensor_fit==CAMERA_SENSOR_FIT_HOR) { + size_r[0]= ar->winx; + size_r[1]= ar->winx/aspect; + } + else { + size_r[0]= ar->winy*aspect; + size_r[1]= ar->winy; } } @@ -941,7 +959,7 @@ void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, Region float size[2]; float dx= 0.0f, dy= 0.0f; - view3d_viewborder_size_get(scene, ar, size); + view3d_viewborder_size_get(scene, v3d->camera, ar, size); size[0]= size[0]*zoomfac; size[1]= size[1]*zoomfac; @@ -1208,6 +1226,21 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); } + if (ca && (ca->flag & CAM_SHOWSENSOR)) { + /* assume fixed sensor width for now */ + + /* float sensor_aspect = ca->sensor_x / ca->sensor_y; */ /* UNUSED */ + float sensor_scale = (x2i-x1i) / ca->sensor_x; + float sensor_height = sensor_scale * ca->sensor_y; + + float ymid = y1i + (y2i-y1i)/2.f; + float sy1= ymid - sensor_height/2.f; + float sy2= ymid + sensor_height/2.f; + + UI_ThemeColorShade(TH_WIRE, 100); + + uiDrawBox(GL_LINE_LOOP, x1i, sy1, x2i, sy2, 2.0f); + } } setlinestyle(0); @@ -2396,10 +2429,12 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in /* render 3d view */ if(rv3d->persp==RV3D_CAMOB && v3d->camera) { float winmat[4][4]; - float _clipsta, _clipend, _lens, _yco, _dx, _dy; + float _clipsta, _clipend, _lens, _yco, _dx, _dy, _sensor_x= DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT; + short _sensor_fit= CAMERA_SENSOR_FIT_AUTO; rctf _viewplane; - object_camera_matrix(&scene->r, v3d->camera, sizex, sizey, 0, winmat, &_viewplane, &_clipsta, &_clipend, &_lens, &_yco, &_dx, &_dy); + object_camera_matrix(&scene->r, v3d->camera, sizex, sizey, 0, winmat, &_viewplane, &_clipsta, &_clipend, &_lens, + &_sensor_x, &_sensor_y, &_sensor_fit, &_yco, &_dx, &_dy); ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat); } @@ -2454,9 +2489,10 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w invert_m4_m4(rv3d.viewmat, rv3d.viewinv); { - float _yco, _dx, _dy; + float _yco, _dx, _dy, _sensor_x= DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT; + short _sensor_fit= CAMERA_SENSOR_FIT_AUTO; rctf _viewplane; - object_camera_matrix(&scene->r, v3d.camera, width, height, 0, rv3d.winmat, &_viewplane, &v3d.near, &v3d.far, &v3d.lens, &_yco, &_dx, &_dy); + object_camera_matrix(&scene->r, v3d.camera, width, height, 0, rv3d.winmat, &_viewplane, &v3d.near, &v3d.far, &v3d.lens, &_sensor_x, &_sensor_y, &_sensor_fit, &_yco, &_dx, &_dy); } mul_m4_m4m4(rv3d.persmat, rv3d.viewmat, rv3d.winmat); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index ea8db17daf0..e7fbdaf1deb 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2255,13 +2255,14 @@ static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was { ARegion *ar= CTX_wm_region(C); RegionView3D *rv3d= CTX_wm_region_view3d(C); + View3D *v3d= CTX_wm_view3d(C); Scene *scene= CTX_data_scene(C); float xfac, yfac; float size[2]; rv3d->camdx= rv3d->camdy= 0.0f; - view3d_viewborder_size_get(scene, ar, size); + view3d_viewborder_size_get(scene, v3d->camera, ar, size); /* 4px is just a little room from the edge of the area */ xfac= (float)ar->winx / (float)(size[0] + 4); @@ -2523,13 +2524,13 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot) } /* sets the view to 1:1 camera/render-pixel */ -static void view3d_set_1_to_1_viewborder(Scene *scene, ARegion *ar) +static void view3d_set_1_to_1_viewborder(Scene *scene, ARegion *ar, View3D *v3d) { RegionView3D *rv3d= ar->regiondata; float size[2]; int im_width= (scene->r.size*scene->r.xsch)/100; - view3d_viewborder_size_get(scene, ar, size); + view3d_viewborder_size_get(scene, v3d->camera, ar, size); rv3d->camzoom= BKE_screen_view3d_zoom_from_fac((float)im_width/size[0]); CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); @@ -2540,7 +2541,7 @@ static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene= CTX_data_scene(C); ARegion *ar= CTX_wm_region(C); - view3d_set_1_to_1_viewborder(scene, ar); + view3d_set_1_to_1_viewborder(scene, ar, CTX_wm_view3d(C)); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index b30030a6b9d..a2c8f971aec 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -84,9 +84,6 @@ * This can be cleaned when I make some new 'mode' icons. */ -#define TEST_EDITMESH if(obedit==0) return; \ - if( (v3d->lay & obedit->lay)==0 ) return; - /* view3d handler codes */ #define VIEW3D_HANDLER_BACKGROUND 1 #define VIEW3D_HANDLER_PROPERTIES 2 @@ -555,12 +552,9 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) if(obedit==NULL && v3d->localvd==NULL) { unsigned int ob_lay = ob ? ob->lay : 0; - + /* Layers */ - if (v3d->scenelock) - uiTemplateLayers(layout, &sceneptr, "layers", &v3dptr, "layers_used", ob_lay); - else - uiTemplateLayers(layout, &v3dptr, "layers", &v3dptr, "layers_used", ob_lay); + uiTemplateLayers(layout, v3d->scenelock ? &sceneptr : &v3dptr, "layers", &v3dptr, "layers_used", ob_lay); /* Scene lock */ uiItemR(layout, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index b087c7ac873..b07d2d1ca73 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -135,7 +135,7 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d); void view3d_clr_clipping(void); void view3d_set_clipping(RegionView3D *rv3d); void add_view3d_after(ListBase *lb, Base *base, int flag); -void view3d_viewborder_size_get(struct Scene *scene, struct ARegion *ar, float size_r[2]); +void view3d_viewborder_size_get(struct Scene *scene, struct Object *camob, struct ARegion *ar, float size_r[2]); void circf(float x, float y, float rad); void circ(float x, float y, float rad); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 2ede76e925e..a5251c18160 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -964,10 +964,14 @@ int ED_view3d_clip_range_get(View3D *v3d, RegionView3D *rv3d, float *clipsta, fl int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend, float *pixsize) { Camera *cam=NULL; - float lens, fac, x1, y1, x2, y2; + float lens, sensor_x =DEFAULT_SENSOR_WIDTH, sensor_y= DEFAULT_SENSOR_HEIGHT, fac, x1, y1, x2, y2; float winx= (float)winxi, winy= (float)winyi; int orth= 0; - + short sensor_fit= CAMERA_SENSOR_FIT_AUTO; + + /* currnetly using sensor size (depends on fov calculating method) */ + float sensor= DEFAULT_SENSOR_WIDTH; + lens= v3d->lens; *clipsta= v3d->near; @@ -990,8 +994,13 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winxi, int winy else if(v3d->camera->type==OB_CAMERA) { cam= v3d->camera->data; lens= cam->lens; + sensor_x= cam->sensor_x; + sensor_y= cam->sensor_y; *clipsta= cam->clipsta; *clipend= cam->clipend; + sensor_fit= cam->sensor_fit; + + sensor= (cam->sensor_fit==CAMERA_SENSOR_FIT_VERT) ? (cam->sensor_y) : (cam->sensor_x); } } } @@ -1022,21 +1031,44 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winxi, int winy if(cam && cam->type==CAM_ORTHO) { /* ortho_scale == 1 means exact 1 to 1 mapping */ float dfac= 2.0f*cam->ortho_scale/fac; - - if(winx>winy) x1= -dfac; - else x1= -winx*dfac/winy; + + if(sensor_fit==CAMERA_SENSOR_FIT_AUTO) { + if(winx>winy) { + x1= -dfac; + y1= -winy*dfac/winx; + } + else { + x1= -winx*dfac/winy; + y1= -dfac; + } + } + else if(sensor_fit==CAMERA_SENSOR_FIT_HOR) { + x1= -dfac; + y1= -winy*dfac/winx; + } + else { + x1= -winx*dfac/winy; + y1= -dfac; + } + x2= -x1; - - if(winx>winy) y1= -winy*dfac/winx; - else y1= -dfac; y2= -y1; + orth= 1; } else { float dfac; - if(winx>winy) dfac= 64.0f/(fac*winx*lens); - else dfac= 64.0f/(fac*winy*lens); + if(sensor_fit==CAMERA_SENSOR_FIT_AUTO) { + if(winx>winy) dfac= (sensor_x * 2.0) / (fac*winx*lens); + else dfac= (sensor_x * 2.0) / (fac*winy*lens); + } + else if(sensor_fit==CAMERA_SENSOR_FIT_HOR) { + dfac= (sensor_x * 2.0) / (fac*winx*lens); + } + else { + dfac= (sensor_y * 2.0) / (fac*winy*lens); + } x1= - *clipsta * winx*dfac; x2= -x1; @@ -1055,8 +1087,8 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winxi, int winy dy += cam->shifty * cam->ortho_scale; } else { - dx += cam->shiftx * (cam->clipsta / cam->lens) * 32.0f; - dy += cam->shifty * (cam->clipsta / cam->lens) * 32.0f; + dx += cam->shiftx * (cam->clipsta / cam->lens) * sensor; + dy += cam->shifty * (cam->clipsta / cam->lens) * sensor; } x1+= dx; @@ -1074,7 +1106,14 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winxi, int winy *pixsize= 1.0f/viewfac; } else { - viewfac= (((winx >= winy)? winx: winy)*lens)/32.0f; + float size= ((winx >= winy)? winx: winy); + + if(sensor_fit==CAMERA_SENSOR_FIT_HOR) + size= winx; + else if(sensor_fit==CAMERA_SENSOR_FIT_VERT) + size= winy; + + viewfac= (size*lens)/sensor; *pixsize= *clipsta/viewfac; } } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 42f28c9fb7c..345172a1c00 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -5753,7 +5753,7 @@ int TimeScale(TransInfo *t, const int UNUSED(mval[2])) /* ************************************ */ -void BIF_TransformSetUndo(char *UNUSED(str)) +void BIF_TransformSetUndo(const char *UNUSED(str)) { // TRANSFORM_FIX_ME //Trans.undostr= str; diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c index 4aa7a657e95..4776cf0af53 100644 --- a/source/blender/editors/util/editmode_undo.c +++ b/source/blender/editors/util/editmode_undo.c @@ -338,7 +338,7 @@ int undo_editmode_valid(const char *undoname) /* get name of undo item, return null if no item with this index */ /* if active pointer, set it to 1 if true */ -char *undo_editmode_get_name(bContext *C, int nr, int *active) +const char *undo_editmode_get_name(bContext *C, int nr, int *active) { UndoElem *uel; diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 6a1819736a2..527537b5efb 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -426,7 +426,7 @@ static EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *totitem) int active, i= 0; while(TRUE) { - char *name= NULL; + const char *name= NULL; if(undosys==UNDOSYSTEM_PARTICLE) { name= PE_undo_get_name(CTX_data_scene(C), i, &active); diff --git a/source/blender/editors/util/util_intern.h b/source/blender/editors/util/util_intern.h index 3e2833ec89a..c6e2d079c28 100644 --- a/source/blender/editors/util/util_intern.h +++ b/source/blender/editors/util/util_intern.h @@ -37,7 +37,7 @@ /* editmode_undo.c */ void undo_editmode_name (struct bContext *C, const char *undoname); int undo_editmode_valid (const char *undoname); -char *undo_editmode_get_name (struct bContext *C, int nr, int *active); +const char *undo_editmode_get_name (struct bContext *C, int nr, int *active); void *undo_editmode_get_prev (struct Object *ob); void undo_editmode_step (struct bContext *C, int step); void undo_editmode_number (struct bContext *C, int nr); diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index 7dabb9898cc..5e0eff69047 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -161,17 +161,18 @@ void GPU_buffer_unbind(void); int GPU_buffer_legacy( struct DerivedMesh *dm ); /* Buffers for non-DerivedMesh drawing */ -void *GPU_build_mesh_buffers(struct GHash *map, struct MVert *mvert, +typedef struct GPU_Buffers GPU_Buffers; +GPU_Buffers *GPU_build_mesh_buffers(struct GHash *map, struct MVert *mvert, struct MFace *mface, int *face_indices, int totface, int *vert_indices, int uniq_verts, int totvert); -void GPU_update_mesh_buffers(void *buffers, struct MVert *mvert, +void GPU_update_mesh_buffers(GPU_Buffers *buffers, struct MVert *mvert, int *vert_indices, int totvert); -void *GPU_build_grid_buffers(struct DMGridData **grids, +GPU_Buffers *GPU_build_grid_buffers(struct DMGridData **grids, int *grid_indices, int totgrid, int gridsize); -void GPU_update_grid_buffers(void *buffers_v, struct DMGridData **grids, +void GPU_update_grid_buffers(GPU_Buffers *buffers_v, struct DMGridData **grids, int *grid_indices, int totgrid, int gridsize, int smooth); -void GPU_draw_buffers(void *buffers); -void GPU_free_buffers(void *buffers); +void GPU_draw_buffers(GPU_Buffers *buffers); +void GPU_free_buffers(GPU_Buffers *buffers); #endif diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 0e877b2c2b9..775d0ac9f4b 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -1279,7 +1279,7 @@ typedef struct { short no[3]; } VertexBufferFormat; -typedef struct { +struct GPU_Buffers { /* opengl buffer handles */ GLuint vert_buf, index_buf; GLenum index_type; @@ -1297,9 +1297,9 @@ typedef struct { int gridsize; unsigned int tot_tri, tot_quad; -} GPU_Buffers; +}; -void GPU_update_mesh_buffers(void *buffers_v, MVert *mvert, +void GPU_update_mesh_buffers(GPU_Buffers *buffers_v, MVert *mvert, int *vert_indices, int totvert) { GPU_Buffers *buffers = buffers_v; @@ -1336,7 +1336,7 @@ void GPU_update_mesh_buffers(void *buffers_v, MVert *mvert, buffers->mvert = mvert; } -void *GPU_build_mesh_buffers(GHash *map, MVert *mvert, MFace *mface, +GPU_Buffers *GPU_build_mesh_buffers(GHash *map, MVert *mvert, MFace *mface, int *face_indices, int totface, int *vert_indices, int tot_uniq_verts, int totvert) @@ -1416,7 +1416,7 @@ void *GPU_build_mesh_buffers(GHash *map, MVert *mvert, MFace *mface, return buffers; } -void GPU_update_grid_buffers(void *buffers_v, DMGridData **grids, +void GPU_update_grid_buffers(GPU_Buffers *buffers_v, DMGridData **grids, int *grid_indices, int totgrid, int gridsize, int smooth) { GPU_Buffers *buffers = buffers_v; @@ -1471,7 +1471,7 @@ void GPU_update_grid_buffers(void *buffers_v, DMGridData **grids, //printf("node updated %p\n", buffers_v); } -void *GPU_build_grid_buffers(DMGridData **UNUSED(grids), int *UNUSED(grid_indices), +GPU_Buffers *GPU_build_grid_buffers(DMGridData **UNUSED(grids), int *UNUSED(grid_indices), int totgrid, int gridsize) { GPU_Buffers *buffers; @@ -1561,7 +1561,7 @@ void *GPU_build_grid_buffers(DMGridData **UNUSED(grids), int *UNUSED(grid_indice return buffers; } -void GPU_draw_buffers(void *buffers_v) +void GPU_draw_buffers(GPU_Buffers *buffers_v) { GPU_Buffers *buffers = buffers_v; @@ -1635,7 +1635,7 @@ void GPU_draw_buffers(void *buffers_v) } } -void GPU_free_buffers(void *buffers_v) +void GPU_free_buffers(GPU_Buffers *buffers_v) { if(buffers_v) { GPU_Buffers *buffers = buffers_v; diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index bf5a612513c..fa40102f89e 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -25,7 +25,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/blenkernel/intern/moviecache.c +/** \file blender/imbuf/intern/moviecache.c * \ingroup bke */ diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h index 8ad6821702a..292f920da66 100644 --- a/source/blender/makesdna/DNA_camera_types.h +++ b/source/blender/makesdna/DNA_camera_types.h @@ -51,6 +51,7 @@ typedef struct Camera { float passepartalpha; float clipsta, clipend; float lens, ortho_scale, drawsize; + float sensor_x, sensor_y; float shiftx, shifty; /* yafray: dof params */ @@ -61,6 +62,9 @@ typedef struct Camera { struct Ipo *ipo; // XXX depreceated... old animation system struct Object *dof_ob; + + char sensor_fit; + char pad[7]; } Camera; /* **************** CAMERA ********************* */ @@ -88,10 +92,18 @@ typedef struct Camera { #define CAM_ANGLETOGGLE 32 #define CAM_DS_EXPAND 64 #define CAM_PANORAMA 128 +#define CAM_SHOWSENSOR 256 /* yafray: dof sampling switch */ /* #define CAM_YF_NO_QMC 512 */ /* depreceated */ +/* Sensor fit */ +#define CAMERA_SENSOR_FIT_AUTO 0 +#define CAMERA_SENSOR_FIT_HOR 1 +#define CAMERA_SENSOR_FIT_VERT 2 + +#define DEFAULT_SENSOR_WIDTH 32.0f +#define DEFAULT_SENSOR_HEIGHT 18.0f #ifdef __cplusplus } diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 3bc7eb85ac4..e7061544ebd 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -111,12 +111,12 @@ typedef struct Object { /* proxy_from is set in target back to the proxy. */ struct Object *proxy, *proxy_group, *proxy_from; struct Ipo *ipo; // XXX depreceated... old animation system - struct Path *path; + /* struct Path *path; */ struct BoundBox *bb; struct bAction *action; // XXX depreceated... old animation system struct bAction *poselib; - struct bPose *pose; - void *data; + struct bPose *pose; /* pose data, armature objects only */ + void *data; /* pointer to objects data - an 'ID' or NULL */ struct bGPdata *gpd; /* Grease Pencil data */ @@ -124,9 +124,9 @@ typedef struct Object { bMotionPath *mpath; /* motion path cache for this object */ ListBase constraintChannels; // XXX depreceated... old animation system - ListBase effect; - ListBase disp; - ListBase defbase; + ListBase effect; // XXX depreceated... keep for readfile + ListBase disp; /* list of DispList, used by lattice, metaballs curve & surfaces */ + ListBase defbase; /* list of bDeformGroup (vertex groups) names and flag only */ ListBase modifiers; /* list of ModifierData structures */ int mode; /* Local object mode */ @@ -156,17 +156,19 @@ typedef struct Object { */ float imat_ren[4][4]; - unsigned int lay; /* copy of Base */ + unsigned int lay; /* copy of Base's layer in the scene */ short flag; /* copy of Base */ short colbits; /* deprecated */ short transflag, protectflag; /* transformation settings and transform locks */ short trackflag, upflag; - short nlaflag, ipoflag; // xxx depreceated... old animation system - short ipowin, scaflag; /* ipowin: blocktype last ipowindow */ - short scavisflag, boundtype; - + short nlaflag; /* used for DopeSheet filtering settings (expanded/collapsed) */ + short ipoflag; // xxx depreceated... old animation system + short scaflag; /* ui state for game logic */ + char scavisflag; /* more display settings for game logic */ + char pad5; + int dupon, dupoff, dupsta, dupend; float sf, ctime; /* sf is time-offset, ctime is the objects current time (XXX timing needs to be revised) */ @@ -193,41 +195,33 @@ typedef struct Object { float min_vel; /* clamp the maximum velocity 0.0 is disabled */ float m_contactProcessingThreshold; float obstacleRad; - char pad0[4]; - + short rotmode; /* rotation mode - uses defines set out in DNA_action_types.h for PoseChannel rotations... */ - - char dt, dtx; - char empty_drawtype, pad1[3]; + + char boundtype; /* bounding box use for drawing */ + char collision_boundtype; /* bounding box type used for collision */ + + char restrictflag; /* for restricting view, select, render etc. accessible in outliner */ + + char dt; /* viewport draw type */ + char dtx; /* viewport draw extra settings */ + char empty_drawtype; float empty_drawsize; float dupfacesca; /* dupliface scale */ - ListBase prop; - ListBase sensors; - ListBase controllers; - ListBase actuators; - + ListBase prop; /* game logic property list (not to be confused with IDProperties) */ + ListBase sensors; /* game logic sensors */ + ListBase controllers; /* game logic controllers */ + ListBase actuators; /* game logic actuators */ + float bbsize[3]; short index; /* custom index, for renderpasses */ unsigned short actdef; /* current deformation group, note: index starts at 1 */ float col[4]; /* object color */ - /** - * Settings for game objects - * bit 0: Object has dynamic behaviour - * bit 2: Object is evaluated by the gameengine - * bit 6: Use Fh settings in Materials - * bit 7: Use face normal to rotate Object - * bit 8: Friction is anisotropic - * bit 9: Object is a ghost - * bit 10: Do rigid body dynamics. - * bit 11: Use bounding object for physics - */ + int gameflag; - /** - * More settings - * bit 15: Always ignore activity culling - */ int gameflag2; + struct BulletSoftBody *bsoft; /* settings for game engine bullet soft body */ short softflag; /* softbody settings */ @@ -236,22 +230,18 @@ typedef struct Object { ListBase constraints; /* object constraints */ ListBase nlastrips; // XXX depreceated... old animation system - ListBase hooks; + ListBase hooks; // XXX depreceated... old animation system ListBase particlesystem; /* particle systems */ struct PartDeflect *pd; /* particle deflector/attractor/collision data */ struct SoftBody *soft; /* if exists, saved in file */ struct Group *dup_group; /* object duplicator for group */ - - short fluidsimFlag; /* NT toggle fluidsim participation on/off */ - - short restrictflag; /* for restricting view, select, render etc. accessible in outliner */ - short shapenr, shapeflag; /* current shape key for menu or pinned, flag for pinning */ + char body_type; /* for now used to temporarily holds the type of collision object */ + char shapeflag; /* flag for pinning */ + short shapenr; /* current shape key for menu or pinned */ float smoothresh; /* smoothresh is phong interpolation ray_shadow correction in render */ - short recalco; /* recalco for temp storage of ob->recalc, bad design warning */ - short body_type; /* for now used to temporarily holds the type of collision object */ - + struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */ struct DerivedMesh *derivedDeform, *derivedFinal; @@ -260,12 +250,11 @@ typedef struct Object { unsigned int state; /* bit masks of game controllers that are active */ unsigned int init_state; /* bit masks of initial state as recorded by the users */ - ListBase gpulamp; /* runtime, for lamps only */ + ListBase gpulamp; /* runtime, for glsl lamp display only */ ListBase pc_ids; ListBase *duplilist; /* for temporary dupli list storage, only for use by RNA API */ float ima_ofs[2]; /* offset for image empties */ - char pad3[8]; } Object; /* Warning, this is not used anymore because hooks are now modifiers */ @@ -286,13 +275,17 @@ typedef struct ObHook { float force; } ObHook; +/* runtime only, but include here for rna access */ typedef struct DupliObject { struct DupliObject *next, *prev; struct Object *ob; unsigned int origlay; - int index, no_draw, type, animated; + int index; float mat[4][4], omat[4][4]; float orco[3], uv[2]; + + short type; /* from Object.transflag */ + char no_draw, animated; } DupliObject; /* **************** OBJECT ********************* */ @@ -333,11 +326,12 @@ typedef struct DupliObject { #define PARVERT1 5 #define PARVERT3 6 #define PARBONE 7 + + /* slow parenting - is not threadsafe and/or may give errors after jumping */ #define PARSLOW 16 /* (short) transflag */ -/*#define OB_OFFS_LOCAL 1*/ /*UNUSED*/ -/* #define OB_QUAT 2 */ /* never used, free flag */ +/* flags 1 and 2 were unused or relics from past features */ #define OB_NEG_SCALE 4 #define OB_DUPLI (8+16+256+512+2048) #define OB_DUPLIFRAMES 8 @@ -353,24 +347,12 @@ typedef struct DupliObject { #define OB_NO_CONSTRAINTS 8192 /* runtime constraints disable */ /* (short) ipoflag */ - // XXX depreceated - old animation system crap -#define OB_DRAWKEY 1 -#define OB_DRAWKEYSEL 2 -#define OB_OFFS_OB 4 -/* #define OB_OFFS_MAT 8 */ /*UNUSED*/ -/* #define OB_OFFS_VKEY 16 */ /*UNUSED*/ -/* #define OB_OFFS_PATH 32 */ /*UNUSED*/ -#define OB_OFFS_PARENT 64 -#define OB_OFFS_PARTICLE 128 - /* get ipo from from action or not? */ -#define OB_ACTION_OB 256 -#define OB_ACTION_KEY 512 - /* for stride edit */ +/* XXX: many old flags for features removed due to incompatability + * with new system and/or other design issues were here + */ + /* for stride/path editing (XXX: NEEDS REVIEW) */ #define OB_DISABLE_PATH 1024 -#define OB_OFFS_PARENTADD 2048 - - /* (short) trackflag / upflag */ #define OB_POSX 0 #define OB_POSY 1 @@ -537,10 +519,7 @@ typedef struct DupliObject { #define OB_SHAPE_EDIT_MODE 4 /* ob->nlaflag */ - // XXX depreceated - old animation system -#define OB_NLA_OVERRIDE (1<<0) -#define OB_NLA_COLLAPSED (1<<1) - + /* WARNING: flags (1<<0) and (1<<1) were from old animsys */ /* object-channel expanded status */ #define OB_ADS_COLLAPSED (1<<10) /* object's ipo-block */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index de04e83e569..cc77df7e679 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -31,7 +31,7 @@ * \ingroup DNA */ -// XXX, temp feature +// XXX, temp feature - campbell #define DURIAN_CAMERA_SWITCH #ifdef __cplusplus diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 8fd79b4b9e5..e1b4d9d138c 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -440,10 +440,10 @@ extern UserDef U; /* from blenkernel blender.c */ #define USER_TOOLTIPS_PYTHON (1 << 26) /* helper macro for checking frame clamping */ -#define FRAMENUMBER_MIN_CLAMP(cfra) \ - { \ - if ((U.flag & USER_NONEGFRAMES) && (cfra < 0)) \ - cfra = 0; \ +#define FRAMENUMBER_MIN_CLAMP(cfra) \ + { \ + if ((U.flag & USER_NONEGFRAMES) && (cfra < 0)) \ + cfra = 0; \ } /* viewzom */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 0e681e57f97..e22789218ad 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -876,37 +876,49 @@ int RNA_collection_length(PointerRNA *ptr, const char *name); void RNA_collection_add(PointerRNA *ptr, const char *name, PointerRNA *r_value); void RNA_collection_clear(PointerRNA *ptr, const char *name); -#define RNA_BEGIN(sptr, itemptr, propname) \ - { \ - CollectionPropertyIterator rna_macro_iter; \ - for(RNA_collection_begin(sptr, propname, &rna_macro_iter); rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) { \ +#define RNA_BEGIN(sptr, itemptr, propname) \ + { \ + CollectionPropertyIterator rna_macro_iter; \ + for(RNA_collection_begin(sptr, propname, &rna_macro_iter); \ + rna_macro_iter.valid; \ + RNA_property_collection_next(&rna_macro_iter)) \ + { \ PointerRNA itemptr= rna_macro_iter.ptr; -#define RNA_END \ - } \ - RNA_property_collection_end(&rna_macro_iter); \ +#define RNA_END \ + } \ + RNA_property_collection_end(&rna_macro_iter); \ } -#define RNA_PROP_BEGIN(sptr, itemptr, prop) \ - { \ - CollectionPropertyIterator rna_macro_iter; \ - for(RNA_property_collection_begin(sptr, prop, &rna_macro_iter); rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) { \ +#define RNA_PROP_BEGIN(sptr, itemptr, prop) \ + { \ + CollectionPropertyIterator rna_macro_iter; \ + for(RNA_property_collection_begin(sptr, prop, &rna_macro_iter); \ + rna_macro_iter.valid; \ + RNA_property_collection_next(&rna_macro_iter)) \ + { \ PointerRNA itemptr= rna_macro_iter.ptr; -#define RNA_PROP_END \ - } \ - RNA_property_collection_end(&rna_macro_iter); \ +#define RNA_PROP_END \ + } \ + RNA_property_collection_end(&rna_macro_iter); \ } -#define RNA_STRUCT_BEGIN(sptr, prop) \ - { \ - CollectionPropertyIterator rna_macro_iter; \ - for(RNA_property_collection_begin(sptr, RNA_struct_iterator_property(sptr->type), &rna_macro_iter); rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) { \ +#define RNA_STRUCT_BEGIN(sptr, prop) \ + { \ + CollectionPropertyIterator rna_macro_iter; \ + for(RNA_property_collection_begin( \ + sptr, \ + RNA_struct_iterator_property(sptr->type), \ + &rna_macro_iter); \ + rna_macro_iter.valid; \ + RNA_property_collection_next(&rna_macro_iter)) \ + { \ PropertyRNA *prop= rna_macro_iter.ptr.data; -#define RNA_STRUCT_END \ - } \ - RNA_property_collection_end(&rna_macro_iter); \ +#define RNA_STRUCT_END \ + } \ + RNA_property_collection_end(&rna_macro_iter); \ } /* check if the idproperty exists, for operators */ diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index adedcbb18b3..891b62f7c79 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -70,25 +70,28 @@ static int replace_if_different(char *tmpfile, const char *dep_files[]) { // return 0; // use for testing had edited rna -#define REN_IF_DIFF \ - { \ - FILE *file_test= fopen(orgfile, "rb"); \ - if(file_test) { \ - fclose(file_test); \ - if(fp_org) fclose(fp_org); \ - if(fp_new) fclose(fp_new); \ - if(remove(orgfile) != 0) { \ - fprintf(stderr, "%s:%d, Remove Error (%s): \"%s\"\n", __FILE__, __LINE__, strerror(errno), orgfile); \ - return -1; \ - } \ - } \ - } \ - if(rename(tmpfile, orgfile) != 0) { \ - fprintf(stderr, "%s:%d, Rename Error (%s): \"%s\" -> \"%s\"\n", __FILE__, __LINE__, strerror(errno), tmpfile, orgfile); \ - return -1; \ - } \ - remove(tmpfile); \ - return 1; \ +#define REN_IF_DIFF \ + { \ + FILE *file_test= fopen(orgfile, "rb"); \ + if(file_test) { \ + fclose(file_test); \ + if(fp_org) fclose(fp_org); \ + if(fp_new) fclose(fp_new); \ + if(remove(orgfile) != 0) { \ + fprintf(stderr, "%s:%d, Remove Error (%s): \"%s\"\n", \ + __FILE__, __LINE__, strerror(errno), orgfile); \ + return -1; \ + } \ + } \ + } \ + if(rename(tmpfile, orgfile) != 0) { \ + fprintf(stderr, "%s:%d, Rename Error (%s): \"%s\" -> \"%s\"\n", \ + __FILE__, __LINE__, strerror(errno), tmpfile, orgfile); \ + return -1; \ + } \ + remove(tmpfile); \ + return 1; \ + /* end REN_IF_DIFF */ diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index a33efda38d0..793d0112af7 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2930,28 +2930,28 @@ int RNA_property_collection_raw_array(PointerRNA *ptr, PropertyRNA *prop, Proper return 1; } -#define RAW_GET(dtype, var, raw, a) \ -{ \ - switch(raw.type) { \ - case PROP_RAW_CHAR: var = (dtype)((char*)raw.array)[a]; break; \ - case PROP_RAW_SHORT: var = (dtype)((short*)raw.array)[a]; break; \ - case PROP_RAW_INT: var = (dtype)((int*)raw.array)[a]; break; \ - case PROP_RAW_FLOAT: var = (dtype)((float*)raw.array)[a]; break; \ - case PROP_RAW_DOUBLE: var = (dtype)((double*)raw.array)[a]; break; \ - default: var = (dtype)0; \ - } \ -} - -#define RAW_SET(dtype, raw, a, var) \ -{ \ - switch(raw.type) { \ - case PROP_RAW_CHAR: ((char*)raw.array)[a] = (char)var; break; \ - case PROP_RAW_SHORT: ((short*)raw.array)[a] = (short)var; break; \ - case PROP_RAW_INT: ((int*)raw.array)[a] = (int)var; break; \ - case PROP_RAW_FLOAT: ((float*)raw.array)[a] = (float)var; break; \ - case PROP_RAW_DOUBLE: ((double*)raw.array)[a] = (double)var; break; \ - default: break; \ - } \ +#define RAW_GET(dtype, var, raw, a) \ +{ \ + switch(raw.type) { \ + case PROP_RAW_CHAR: var = (dtype)((char*)raw.array)[a]; break; \ + case PROP_RAW_SHORT: var = (dtype)((short*)raw.array)[a]; break; \ + case PROP_RAW_INT: var = (dtype)((int*)raw.array)[a]; break; \ + case PROP_RAW_FLOAT: var = (dtype)((float*)raw.array)[a]; break; \ + case PROP_RAW_DOUBLE: var = (dtype)((double*)raw.array)[a]; break; \ + default: var = (dtype)0; \ + } \ +} + +#define RAW_SET(dtype, raw, a, var) \ +{ \ + switch(raw.type) { \ + case PROP_RAW_CHAR: ((char*)raw.array)[a] = (char)var; break; \ + case PROP_RAW_SHORT: ((short*)raw.array)[a] = (short)var; break; \ + case PROP_RAW_INT: ((int*)raw.array)[a] = (int)var; break; \ + case PROP_RAW_FLOAT: ((float*)raw.array)[a] = (float)var; break; \ + case PROP_RAW_DOUBLE: ((double*)raw.array)[a] = (double)var; break; \ + default: break; \ + } \ } int RNA_raw_type_sizeof(RawPropertyType type) diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 596e1a7f357..db71dee26ce 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -109,6 +109,18 @@ static StructRNA* rna_Actuator_refine(struct PointerRNA *ptr) } } +void rna_Actuator_name_set(PointerRNA *ptr, const char *value) +{ + bActuator *act= (bActuator *)ptr->data; + + BLI_strncpy_utf8(act->name, value, sizeof(act->name)); + + if (ptr->id.data) { + Object *ob= (Object *)ptr->id.data; + BLI_uniquename(&ob->actuators, act, "Actuator", '.', offsetof(bActuator, name), sizeof(act->name)); + } +} + static void rna_Actuator_type_set(struct PointerRNA *ptr, int value) { bActuator *act= (bActuator *)ptr->data; @@ -525,6 +537,7 @@ void rna_def_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Actuator_name_set"); RNA_def_struct_name_property(srna, prop); prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 9e89c4aaab0..1e7a969caaa 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -40,19 +40,65 @@ #ifdef RNA_RUNTIME #include "BKE_object.h" +#include "BKE_depsgraph.h" /* only for rad/deg conversion! can remove later */ +static float get_camera_sensor(Camera *cam) +{ + if(cam->sensor_fit==CAMERA_SENSOR_FIT_AUTO) { + return cam->sensor_x; + } + else if(cam->sensor_fit==CAMERA_SENSOR_FIT_HOR) { + return cam->sensor_x; + } + else { + return cam->sensor_y; + } +} + static float rna_Camera_angle_get(PointerRNA *ptr) { Camera *cam= ptr->id.data; - - return lens_to_angle(cam->lens); + float sensor= get_camera_sensor(cam); + return focallength_to_fov(cam->lens, sensor); } static void rna_Camera_angle_set(PointerRNA *ptr, float value) { Camera *cam= ptr->id.data; - cam->lens= angle_to_lens(value); + float sensor= get_camera_sensor(cam); + cam->lens= fov_to_focallength(value, sensor); +} + +static float rna_Camera_angle_x_get(PointerRNA *ptr) +{ + Camera *cam= ptr->id.data; + return focallength_to_fov(cam->lens, cam->sensor_x); +} + +static void rna_Camera_angle_x_set(PointerRNA *ptr, float value) +{ + Camera *cam= ptr->id.data; + cam->lens= fov_to_focallength(value, cam->sensor_x); +} + +static float rna_Camera_angle_y_get(PointerRNA *ptr) +{ + Camera *cam= ptr->id.data; + return focallength_to_fov(cam->lens, cam->sensor_y); +} + +static void rna_Camera_angle_y_set(PointerRNA *ptr, float value) +{ + Camera *cam= ptr->id.data; + cam->lens= fov_to_focallength(value, cam->sensor_y); +} + +static void rna_Camera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + Camera *camera= (Camera*)ptr->id.data; + + DAG_id_tag_update(&camera->id, 0); } #else @@ -79,6 +125,11 @@ void RNA_def_camera(BlenderRNA *brna) {0, "MILLIMETERS", 0, "Millimeters", ""}, {CAM_ANGLETOGGLE, "DEGREES", 0, "Degrees", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem sensor_fit_items[] = { + {CAMERA_SENSOR_FIT_AUTO, "AUTO", 0, "Auto", "Calculate field of view using sensor size, with direction depending on image resolution"}, + {CAMERA_SENSOR_FIT_HOR, "HORIZONTAL", 0, "Horizontal", "Calculate field of view using sensor width"}, + {CAMERA_SENSOR_FIT_VERT, "VERTICAL", 0, "Vertical", "Calculate field of view using sensor height"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Camera", "ID"); RNA_def_struct_ui_text(srna, "Camera", "Camera datablock for storing camera settings"); @@ -88,7 +139,7 @@ void RNA_def_camera(BlenderRNA *brna) prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_type_items); RNA_def_property_ui_text(prop, "Type", "Camera types"); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update"); prop= RNA_def_property(srna, "show_guide", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dtx"); @@ -96,7 +147,13 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_ENUM_FLAG); RNA_def_property_ui_text(prop, "Composition Guides", "Draw overlay"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); - + + prop= RNA_def_property(srna, "sensor_fit", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "sensor_fit"); + RNA_def_property_enum_items(prop, sensor_fit_items); + RNA_def_property_ui_text(prop, "Sensor Fit", "Mode of calculating field of view from sensor dimensions and focal length"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update"); + /* Number values */ prop= RNA_def_property(srna, "passepartout_alpha", PROP_FLOAT, PROP_FACTOR); @@ -104,6 +161,27 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Passepartout Alpha", "Opacity (alpha) of the darkened overlay in Camera view"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + prop= RNA_def_property(srna, "angle_x", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_range(prop, M_PI * (0.367/180.0), M_PI * (172.847/180.0)); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Horizontal FOV", "Camera lens horizontal field of view in degrees"); + RNA_def_property_float_funcs(prop, "rna_Camera_angle_x_get", "rna_Camera_angle_x_set", NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update"); + + prop= RNA_def_property(srna, "angle_y", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_range(prop, M_PI * (0.367/180.0), M_PI * (172.847/180.0)); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Vertical FOV", "Camera lens vertical field of view in degrees"); + RNA_def_property_float_funcs(prop, "rna_Camera_angle_y_get", "rna_Camera_angle_y_set", NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update"); + + prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_range(prop, M_PI * (0.367/180.0), M_PI * (172.847/180.0)); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Field of View", "Camera lens field of view in degrees"); + RNA_def_property_float_funcs(prop, "rna_Camera_angle_get", "rna_Camera_angle_set", NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update"); + prop= RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipsta"); RNA_def_property_range(prop, 0.001f, FLT_MAX); @@ -120,20 +198,27 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "lens"); RNA_def_property_range(prop, 1.0f, 5000.0f); RNA_def_property_ui_text(prop, "Focal Length", "Perspective Camera lens value in millimeters"); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); - - prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_range(prop, M_PI * (0.367/180.0), M_PI * (172.847/180.0)); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Angle", "Perspective Camera lens field of view in degrees"); - RNA_def_property_float_funcs(prop, "rna_Camera_angle_get", "rna_Camera_angle_set", NULL); /* only for deg/rad conversion */ - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update"); + + prop= RNA_def_property(srna, "sensor_width", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "sensor_x"); + RNA_def_property_range(prop, 1.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 1.0f, 100.f, 1, 2); + RNA_def_property_ui_text(prop, "Sensor Width", "Horizontal size of the image sensor area in millimeters"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update"); + + prop= RNA_def_property(srna, "sensor_height", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "sensor_y"); + RNA_def_property_range(prop, 1.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 1.0f, 100.f, 1, 2); + RNA_def_property_ui_text(prop, "Sensor Height", "Vertical size of the image sensor area in millimeters"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update"); prop= RNA_def_property(srna, "ortho_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ortho_scale"); RNA_def_property_range(prop, 0.01f, 4000.0f); RNA_def_property_ui_text(prop, "Orthographic Scale", "Orthographic Camera scale (similar to zoom)"); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update"); prop= RNA_def_property(srna, "draw_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "drawsize"); @@ -147,14 +232,14 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_range(prop, -10.0f, 10.0f); RNA_def_property_ui_range(prop, -2.0, 2.0, 1, 3); RNA_def_property_ui_text(prop, "Shift X", "Perspective Camera horizontal shift"); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update"); prop= RNA_def_property(srna, "shift_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "shifty"); RNA_def_property_range(prop, -10.0f, 10.0f); RNA_def_property_ui_range(prop, -2.0, 2.0, 1, 3); RNA_def_property_ui_text(prop, "Shift Y", "Perspective Camera vertical shift"); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update"); prop= RNA_def_property(srna, "dof_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "YF_dofdist"); @@ -188,6 +273,11 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Name", "Show the active Camera's name in Camera view"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + prop= RNA_def_property(srna, "show_sensor", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_SHOWSENSOR); + RNA_def_property_ui_text(prop, "Show Sensor Size", "Show sensor size (film gate) in Camera view"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + prop= RNA_def_property(srna, "lens_unit", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, prop_lens_unit_items); diff --git a/source/blender/makesrna/intern/rna_camera_api.c b/source/blender/makesrna/intern/rna_camera_api.c index bf3db58e35e..2af0524861a 100644 --- a/source/blender/makesrna/intern/rna_camera_api.c +++ b/source/blender/makesrna/intern/rna_camera_api.c @@ -36,6 +36,8 @@ #ifdef RNA_RUNTIME #include "DNA_scene_types.h" + +#include "BKE_camera.h" #include "BKE_context.h" #include "BKE_object.h" diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 59d23b7a878..60144e0cf7f 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -167,19 +167,20 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr) /* helper macro for use here to try and get the path * - this calls the standard code for getting a path to a texture... */ -#define COLRAMP_GETPATH \ -{ \ -prop= RNA_struct_find_property(&ramp_ptr, "elements"); \ -if (prop) { \ -index= RNA_property_collection_lookup_index(&ramp_ptr, prop, ptr); \ -if (index >= 0) { \ -char *texture_path= rna_ColorRamp_path(&ramp_ptr); \ -path= BLI_sprintfN("%s.elements[%d]", texture_path, index); \ -MEM_freeN(texture_path); \ -} \ -} \ + +#define COLRAMP_GETPATH \ +{ \ + prop= RNA_struct_find_property(&ramp_ptr, "elements"); \ + if (prop) { \ + index= RNA_property_collection_lookup_index(&ramp_ptr, prop, ptr); \ + if (index >= 0) { \ + char *texture_path= rna_ColorRamp_path(&ramp_ptr); \ + path= BLI_sprintfN("%s.elements[%d]", texture_path, index); \ + MEM_freeN(texture_path); \ + } \ + } \ } - + /* determine the path from the ID-block to the ramp */ // FIXME: this is a very slow way to do it, but it will have to suffice... if (ptr->id.data) { diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index fe899f99ed2..89239c10ffd 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -75,6 +75,18 @@ static struct StructRNA* rna_Controller_refine(struct PointerRNA *ptr) } } +void rna_Constroller_name_set(PointerRNA *ptr, const char *value) +{ + bController *cont= (bController *)ptr->data; + + BLI_strncpy_utf8(cont->name, value, sizeof(cont->name)); + + if (ptr->id.data) { + Object *ob= (Object *)ptr->id.data; + BLI_uniquename(&ob->controllers, cont, "Controller", '.', offsetof(bController, name), sizeof(cont->name)); + } +} + static void rna_Controller_type_set(struct PointerRNA *ptr, int value) { bController *cont= (bController *)ptr->data; @@ -177,6 +189,7 @@ void RNA_def_controller(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Constroller_name_set"); RNA_def_struct_name_property(srna, prop); RNA_def_property_update(prop, NC_LOGIC, NULL); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 1f52b0ac149..93fdc2b2136 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -268,9 +268,6 @@ static void rna_Curve_active_textbox_index_range(PointerRNA *ptr, int *min, int static void rna_Curve_dimension_set(PointerRNA *ptr, int value) { Curve *cu= (Curve*)ptr->id.data; - ListBase *nurbs= BKE_curve_nurbs(cu); - Nurb *nu= nurbs->first; - if(value==CU_3D) cu->flag |= CU_3D; else cu->flag &= ~CU_3D; diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 92c84da165b..076bdfe1964 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -324,7 +324,7 @@ void RNA_def_main(BlenderRNA *brna) prop= RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Main_is_dirty_get", NULL); - RNA_def_property_ui_text(prop, "File is Saved", "Have recent edits been saved to disk"); + RNA_def_property_ui_text(prop, "File Has Unsaved Changes", "Have recent edits been saved to disk"); prop= RNA_def_property(srna, "is_saved", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 1b80e33b40c..dfa368d6b94 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -43,9 +43,11 @@ #ifdef RNA_RUNTIME #include "BKE_main.h" +#include "BKE_camera.h" #include "BKE_curve.h" #include "BKE_mesh.h" #include "BKE_armature.h" +#include "BKE_lamp.h" #include "BKE_library.h" #include "BKE_object.h" #include "BKE_material.h" diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 05dc8ac0c99..df2b2881c03 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -902,11 +902,11 @@ static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value) break; case OB_BODY_TYPE_OCCLUDER: ob->gameflag |= OB_OCCLUDER; - ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_DYNAMIC|OB_NAVMESH); + ob->gameflag &= ~(OB_SENSOR|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION|OB_DYNAMIC|OB_NAVMESH); break; case OB_BODY_TYPE_NAVMESH: ob->gameflag |= OB_NAVMESH; - ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_DYNAMIC|OB_OCCLUDER); + ob->gameflag &= ~(OB_SENSOR|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION|OB_DYNAMIC|OB_OCCLUDER); if (ob->type == OB_MESH) { /* could be moved into mesh UI but for now ensure mesh data layer */ @@ -915,7 +915,7 @@ static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value) break; case OB_BODY_TYPE_NO_COLLISION: - ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_OCCLUDER|OB_DYNAMIC|OB_NAVMESH); + ob->gameflag &= ~(OB_SENSOR|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION|OB_OCCLUDER|OB_DYNAMIC|OB_NAVMESH); break; case OB_BODY_TYPE_STATIC: ob->gameflag |= OB_COLLISION; @@ -949,10 +949,10 @@ static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value) if (ob->type == OB_MESH) { /* this is needed to refresh the derived meshes draw func */ DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); - WM_main_add_notifier(NC_OBJECT|ND_DRAW, ptr->id.data); } } + WM_main_add_notifier(NC_OBJECT|ND_DRAW, ptr->id.data); } static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr) @@ -1533,9 +1533,10 @@ static void rna_def_object_game_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "use_collision_bounds", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_BOUNDS); RNA_def_property_ui_text(prop, "Use Collision Bounds", "Specify a collision bounds type other than the default"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); prop= RNA_def_property(srna, "collision_bounds_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "boundtype"); + RNA_def_property_enum_sdna(prop, NULL, "collision_boundtype"); RNA_def_property_enum_items(prop, collision_bounds_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_collision_bounds_itemf"); RNA_def_property_ui_text(prop, "Collision Bounds", "Select the collision type"); @@ -1804,8 +1805,6 @@ static void rna_def_object(BlenderRNA *brna) {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Draw bounds as sphere"}, {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Draw bounds as cylinder"}, {OB_BOUND_CONE, "CONE", 0, "Cone", "Draw bounds as cone"}, - {OB_BOUND_TRIANGLE_MESH, "POLYHEDRON", 0, "Polyhedron", "Draw bounds as polyhedron"}, - {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", "Draw bounds as capsule"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem dupli_items[] = { @@ -2212,13 +2211,20 @@ static void rna_def_object(BlenderRNA *brna) rna_def_animviz_common(srna); rna_def_motionpath_common(srna); - /* duplicates */ - // XXX: evil old crap + /* slow parenting */ + // XXX: evil old crap prop= RNA_def_property(srna, "use_slow_parent", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "partype", PARSLOW); - RNA_def_property_ui_text(prop, "Slow Parent", "Create a delay in the parent relationship"); + RNA_def_property_ui_text(prop, "Slow Parent", "Create a delay in the parent relationship (Beware: this isn't renderfarm safe and may be invalid after jumping around the timeline)"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); - + + prop= RNA_def_property(srna, "slow_parent_offset", PROP_FLOAT, PROP_NONE|PROP_UNIT_TIME); + RNA_def_property_float_sdna(prop, NULL, "sf"); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); + RNA_def_property_ui_text(prop, "Slow Parent Offset", "Amount of delay in the parent relationship"); + RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); + + /* duplicates */ prop= RNA_def_property(srna, "dupli_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag"); RNA_def_property_enum_items(prop, dupli_items); @@ -2227,7 +2233,7 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "use_dupli_frames_speed", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED); - RNA_def_property_ui_text(prop, "Dupli Frames Speed", "Set dupliframes to use the frame"); // TODO, better descriptio! + RNA_def_property_ui_text(prop, "Dupli Frames Speed", "Set dupliframes to use the current frame instead of parent curve's evaluation time"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); prop= RNA_def_property(srna, "use_dupli_vertices_rotation", PROP_BOOLEAN, PROP_NONE); @@ -2287,34 +2293,7 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "is_duplicator", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLI); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - /* time offset */ - prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE|PROP_UNIT_TIME); - RNA_def_property_float_sdna(prop, NULL, "sf"); - RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); - RNA_def_property_ui_text(prop, "Time Offset", "Animation offset in frames for F-Curve and dupligroup instances"); - RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); - - prop= RNA_def_property(srna, "use_time_offset_edit", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_OB); - RNA_def_property_ui_text(prop, "Time Offset Edit", - "Use time offset when inserting keys and display time offset for F-Curve and action views"); - - prop= RNA_def_property(srna, "use_time_offset_parent", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARENT); - RNA_def_property_ui_text(prop, "Time Offset Parent", "Apply the time offset to this object's parent relationship"); - RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); - - prop= RNA_def_property(srna, "use_time_offset_particle", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARTICLE); - RNA_def_property_ui_text(prop, "Time Offset Particle", "Let the time offset work on the particle effect"); - RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); - - prop= RNA_def_property(srna, "use_time_offset_add_parent", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARENTADD); - RNA_def_property_ui_text(prop, "Time Offset Add Parent", "Add the parent's time offset value"); - RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); - + /* drawing */ prop= RNA_def_property(srna, "draw_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dt"); diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 217b50b38e5..ba58a66a2d6 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -102,6 +102,18 @@ static StructRNA* rna_Sensor_refine(struct PointerRNA *ptr) } } +void rna_Sensor_name_set(PointerRNA *ptr, const char *value) +{ + bSensor *sens= (bSensor *)ptr->data; + + BLI_strncpy_utf8(sens->name, value, sizeof(sens->name)); + + if (ptr->id.data) { + Object *ob= (Object *)ptr->id.data; + BLI_uniquename(&ob->sensors, sens, "Sensor", '.', offsetof(bSensor, name), sizeof(sens->name)); + } +} + static void rna_Sensor_type_set(struct PointerRNA *ptr, int value) { bSensor *sens= (bSensor *)ptr->data; @@ -260,6 +272,7 @@ static void rna_def_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", "Sensor name"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Sensor_name_set"); RNA_def_struct_name_property(srna, prop); RNA_def_property_update(prop, NC_LOGIC, NULL); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index c7f7fe5feea..dfbdafd7d18 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -821,7 +821,7 @@ static int operator_execute(bContext *C, wmOperator *op) void *ret; int result; - RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr); + RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); func= &rna_Operator_execute_func; /* RNA_struct_find_function(&opr, "execute"); */ RNA_parameter_list_create(&list, &opr, func); @@ -847,7 +847,7 @@ static int operator_check(bContext *C, wmOperator *op) void *ret; int result; - RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr); + RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); func= &rna_Operator_check_func; /* RNA_struct_find_function(&opr, "check"); */ RNA_parameter_list_create(&list, &opr, func); @@ -872,7 +872,7 @@ static int operator_invoke(bContext *C, wmOperator *op, wmEvent *event) void *ret; int result; - RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr); + RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); func= &rna_Operator_invoke_func; /* RNA_struct_find_function(&opr, "invoke"); */ RNA_parameter_list_create(&list, &opr, func); @@ -899,7 +899,7 @@ static int operator_modal(bContext *C, wmOperator *op, wmEvent *event) void *ret; int result; - RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr); + RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); func= &rna_Operator_modal_func; /* RNA_struct_find_function(&opr, "modal"); */ RNA_parameter_list_create(&list, &opr, func); @@ -923,7 +923,7 @@ static void operator_draw(bContext *C, wmOperator *op) ParameterList list; FunctionRNA *func; - RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr); + RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); func= &rna_Operator_draw_func; /* RNA_struct_find_function(&opr, "draw"); */ RNA_parameter_list_create(&list, &opr, func); @@ -944,7 +944,7 @@ static int operator_cancel(bContext *C, wmOperator *op) void *ret; int result; - RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr); + RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); func= &rna_Operator_cancel_func; /* RNA_struct_find_function(&opr, "cancel"); */ RNA_parameter_list_create(&list, &opr, func); diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index 87989b541f5..ed28dda8076 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -115,12 +115,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, faceMap = MEM_callocN(sizeof(*faceMap) * maxFaces, "build modifier faceMap"); for(i = 0; i < maxFaces; ++i) faceMap[i] = i; - if (ob) { - frac = bsystem_time(md->scene, ob, md->scene->r.cfra, - bmd->start - 1.0f) / bmd->length; - } else { - frac = BKE_curframe(md->scene) - bmd->start / bmd->length; - } + frac = BKE_curframe(md->scene) - bmd->start / bmd->length; CLAMP(frac, 0.0f, 1.0f); numFaces = dm->getNumFaces(dm) * frac; diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 70766b55a1e..e317c97c4d3 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -812,10 +812,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, /* timestep= psys_get_timestep(&sim); */ - //if(part->flag & PART_GLOB_TIME) - cfra= BKE_curframe(scene); - //else - // cfra=bsystem_time(scene, ob,(float)scene->r.cfra,0.0); + cfra= BKE_curframe(scene); /* hash table for vertice <-> particle relations */ vertpahash= BLI_edgehash_new(); diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 2ddbae28cb6..bbaab989a2b 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -38,6 +38,7 @@ #include "DNA_meshdata_types.h" #include "DNA_camera_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BLI_math.h" #include "BLI_string.h" @@ -159,7 +160,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, float scax= umd->scalex ? umd->scalex : 1.0f; float scay= umd->scaley ? umd->scaley : 1.0f; int free_uci= 0; - + aspect = aspx / aspy; for(i = 0; i < umd->num_projectors; ++i) @@ -194,16 +195,28 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, free_uci= 1; } else { - float scale= (cam->type == CAM_PERSP) ? cam->clipsta * 32.0f / cam->lens : cam->ortho_scale; + float sensor= (cam->sensor_fit == CAMERA_SENSOR_FIT_VERT) ? (cam->sensor_y) : cam->sensor_x; + float scale= (cam->type == CAM_PERSP) ? cam->clipsta * sensor / cam->lens : cam->ortho_scale; float xmax, xmin, ymax, ymin; - if(aspect > 1.0f) { + if(cam->sensor_fit==CAMERA_SENSOR_FIT_AUTO) { + if(aspect > 1.0f) { + xmax = 0.5f * scale; + ymax = xmax / aspect; + } else { + ymax = 0.5f * scale; + xmax = ymax * aspect; + } + } + else if(cam->sensor_fit==CAMERA_SENSOR_FIT_HOR) { xmax = 0.5f * scale; ymax = xmax / aspect; - } else { + } + else { ymax = 0.5f * scale; xmax = ymax * aspect; } + xmin = -xmax; ymin = -ymax; diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index b8282f2c452..929b87618d8 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -1358,24 +1358,24 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy) tsM[7] = sc*(cf[1]*cf[2] + cf[3]*cf[2]*cf[2] - cf[1]*cf[3]*cf[3] - cf[3]*cf[3]*cf[3] - cf[3]*cf[2] + cf[3]); tsM[8] = sc*(cf[3]*(cf[1] + cf[3]*cf[2])); -#define YVV(L)\ -{\ - W[0] = cf[0]*X[0] + cf[1]*X[0] + cf[2]*X[0] + cf[3]*X[0];\ - W[1] = cf[0]*X[1] + cf[1]*W[0] + cf[2]*X[0] + cf[3]*X[0];\ - W[2] = cf[0]*X[2] + cf[1]*W[1] + cf[2]*W[0] + cf[3]*X[0];\ - for (i=3; i<L; i++)\ - W[i] = cf[0]*X[i] + cf[1]*W[i-1] + cf[2]*W[i-2] + cf[3]*W[i-3];\ - tsu[0] = W[L-1] - X[L-1];\ - tsu[1] = W[L-2] - X[L-1];\ - tsu[2] = W[L-3] - X[L-1];\ - tsv[0] = tsM[0]*tsu[0] + tsM[1]*tsu[1] + tsM[2]*tsu[2] + X[L-1];\ - tsv[1] = tsM[3]*tsu[0] + tsM[4]*tsu[1] + tsM[5]*tsu[2] + X[L-1];\ - tsv[2] = tsM[6]*tsu[0] + tsM[7]*tsu[1] + tsM[8]*tsu[2] + X[L-1];\ - Y[L-1] = cf[0]*W[L-1] + cf[1]*tsv[0] + cf[2]*tsv[1] + cf[3]*tsv[2];\ - Y[L-2] = cf[0]*W[L-2] + cf[1]*Y[L-1] + cf[2]*tsv[0] + cf[3]*tsv[1];\ - Y[L-3] = cf[0]*W[L-3] + cf[1]*Y[L-2] + cf[2]*Y[L-1] + cf[3]*tsv[0];\ - for (i=L-4; i>=0; i--)\ - Y[i] = cf[0]*W[i] + cf[1]*Y[i+1] + cf[2]*Y[i+2] + cf[3]*Y[i+3];\ +#define YVV(L) \ +{ \ + W[0] = cf[0]*X[0] + cf[1]*X[0] + cf[2]*X[0] + cf[3]*X[0]; \ + W[1] = cf[0]*X[1] + cf[1]*W[0] + cf[2]*X[0] + cf[3]*X[0]; \ + W[2] = cf[0]*X[2] + cf[1]*W[1] + cf[2]*W[0] + cf[3]*X[0]; \ + for (i=3; i<L; i++) \ + W[i] = cf[0]*X[i] + cf[1]*W[i-1] + cf[2]*W[i-2] + cf[3]*W[i-3]; \ + tsu[0] = W[L-1] - X[L-1]; \ + tsu[1] = W[L-2] - X[L-1]; \ + tsu[2] = W[L-3] - X[L-1]; \ + tsv[0] = tsM[0]*tsu[0] + tsM[1]*tsu[1] + tsM[2]*tsu[2] + X[L-1]; \ + tsv[1] = tsM[3]*tsu[0] + tsM[4]*tsu[1] + tsM[5]*tsu[2] + X[L-1]; \ + tsv[2] = tsM[6]*tsu[0] + tsM[7]*tsu[1] + tsM[8]*tsu[2] + X[L-1]; \ + Y[L-1] = cf[0]*W[L-1] + cf[1]*tsv[0] + cf[2]*tsv[1] + cf[3]*tsv[2]; \ + Y[L-2] = cf[0]*W[L-2] + cf[1]*Y[L-1] + cf[2]*tsv[0] + cf[3]*tsv[1]; \ + Y[L-3] = cf[0]*W[L-3] + cf[1]*Y[L-2] + cf[2]*Y[L-1] + cf[3]*tsv[0]; \ + for (i=L-4; i>=0; i--) \ + Y[i] = cf[0]*W[i] + cf[1]*Y[i+1] + cf[2]*Y[i+2] + cf[3]*Y[i+3]; \ } // intermediate buffers diff --git a/source/blender/nodes/composite/node_composite_util.h b/source/blender/nodes/composite/node_composite_util.h index 9ebca8688b4..6da9b901e76 100644 --- a/source/blender/nodes/composite/node_composite_util.h +++ b/source/blender/nodes/composite/node_composite_util.h @@ -57,6 +57,7 @@ #include "BLI_utildefines.h" #include "BKE_blender.h" +#include "BKE_camera.h" #include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_image.h" diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c index d9774453d3e..b542954948a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c +++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c @@ -35,8 +35,8 @@ /* **************** ALPHAOVER ******************** */ static bNodeSocketTemplate cmp_node_alphaover_in[]= { { SOCK_FLOAT, 1, "Fac", 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_alphaover_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c index fe04e69993f..17038fd6780 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c @@ -33,8 +33,8 @@ /* **************** BILATERALBLUR ******************** */ static bNodeSocketTemplate cmp_node_bilateralblur_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, - { SOCK_RGBA, 1, "Determinator", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, + { SOCK_RGBA, 1, "Determinator", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; @@ -43,43 +43,47 @@ static bNodeSocketTemplate cmp_node_bilateralblur_out[]= { { -1, 0, "" } }; -#define INIT_C3\ - mean0 = 1; mean1[0] = src[0];mean1[1] = src[1];mean1[2] = src[2];mean1[3] = src[3]; +#define INIT_C3 \ + mean0 = 1; \ + mean1[0] = src[0]; \ + mean1[1] = src[1]; \ + mean1[2] = src[2]; \ + mean1[3] = src[3]; /* finds color distances */ -#define COLOR_DISTANCE_C3(c1, c2)\ - ((c1[0] - c2[0])*(c1[0] - c2[0]) + \ - (c1[1] - c2[1])*(c1[1] - c2[1]) + \ - (c1[2] - c2[2])*(c1[2] - c2[2]) + \ - (c1[3] - c2[3])*(c1[3] - c2[3])) +#define COLOR_DISTANCE_C3(c1, c2) \ + ((c1[0] - c2[0])*(c1[0] - c2[0]) + \ + (c1[1] - c2[1])*(c1[1] - c2[1]) + \ + (c1[2] - c2[2])*(c1[2] - c2[2]) + \ + (c1[3] - c2[3])*(c1[3] - c2[3])) /* this is the main kernel function for comparing color distances and adding them weighted to the final color */ -#define KERNEL_ELEMENT_C3(k)\ - temp_color = src + deltas[k];\ - ref_color = ref + deltas[k];\ - w = weight_tab[k] + COLOR_DISTANCE_C3(ref, ref_color )*i2sigma_color;\ - w = 1./(w*w + 1); \ - mean0 += w;\ - mean1[0] += temp_color[0]*w; \ - mean1[1] += temp_color[1]*w; \ - mean1[2] += temp_color[2]*w; \ +#define KERNEL_ELEMENT_C3(k) \ + temp_color = src + deltas[k]; \ + ref_color = ref + deltas[k]; \ + w = weight_tab[k] + COLOR_DISTANCE_C3(ref, ref_color )*i2sigma_color; \ + w = 1.0/(w*w + 1); \ + mean0 += w; \ + mean1[0] += temp_color[0]*w; \ + mean1[1] += temp_color[1]*w; \ + mean1[2] += temp_color[2]*w; \ mean1[3] += temp_color[3]*w; /* write blurred values to image */ -#define UPDATE_OUTPUT_C3\ - mean0 = 1./mean0;\ - dest[x*pix + 0] = mean1[0]*mean0; \ - dest[x*pix + 1] = mean1[1]*mean0; \ - dest[x*pix + 2] = mean1[2]*mean0; \ +#define UPDATE_OUTPUT_C3 \ + mean0 = 1.0/mean0; \ + dest[x*pix + 0] = mean1[0]*mean0; \ + dest[x*pix + 1] = mean1[1]*mean0; \ + dest[x*pix + 2] = mean1[2]*mean0; \ dest[x*pix + 3] = mean1[3]*mean0; /* initializes deltas for fast access to neighbour pixels */ -#define INIT_3X3_DELTAS( deltas, step, nch ) \ - ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \ - (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \ - (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \ - (deltas)[6] = (step), (deltas)[7] = (step) + (nch)); +#define INIT_3X3_DELTAS( deltas, step, nch ) \ + ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \ + (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \ + (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \ + (deltas)[6] = (step), (deltas)[7] = (step) + (nch)); /* code of this node was heavily inspired by the smooth function of opencv library. diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c index 2db80385951..188ac653506 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.c +++ b/source/blender/nodes/composite/nodes/node_composite_blur.c @@ -35,7 +35,7 @@ /* **************** BLUR ******************** */ static bNodeSocketTemplate cmp_node_blur_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, "Size", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_brightness.c b/source/blender/nodes/composite/nodes/node_composite_brightness.c index 95099e7adfb..9153e3899fc 100644 --- a/source/blender/nodes/composite/nodes/node_composite_brightness.c +++ b/source/blender/nodes/composite/nodes/node_composite_brightness.c @@ -37,7 +37,7 @@ /* **************** Brigh and contrsast ******************** */ static bNodeSocketTemplate cmp_node_brightcontrast_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, "Bright", 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, { SOCK_FLOAT, 1, "Contrast", 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, { -1, 0, "" } diff --git a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c index dbdfc6712dc..10f0afb6cf6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c @@ -35,7 +35,7 @@ /* ******************* Channel Matte Node ********************************* */ static bNodeSocketTemplate cmp_node_channel_matte_in[]={ - {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f}, + {SOCK_RGBA,1,"Image", 1.0f, 1.0f, 1.0f, 1.0f}, {-1,0,""} }; diff --git a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c index 71bb7c35d01..25891aeaa68 100644 --- a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c @@ -34,8 +34,8 @@ /* ******************* Chroma Key ********************************************************** */ static bNodeSocketTemplate cmp_node_chroma_in[]={ - {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f}, - {SOCK_RGBA,1,"Key Color", 0.8f, 0.8f, 0.8f, 1.0f}, + {SOCK_RGBA,1,"Image", 1.0f, 1.0f, 1.0f, 1.0f}, + {SOCK_RGBA,1,"Key Color", 1.0f, 1.0f, 1.0f, 1.0f}, {-1,0,""} }; diff --git a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c index a82d8cf1f41..3dfc3a193a8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c @@ -34,8 +34,8 @@ /* ******************* Color Key ********************************************************** */ static bNodeSocketTemplate cmp_node_color_in[]={ - {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f}, - {SOCK_RGBA,1,"Key Color", 0.8f, 0.8f, 0.8f, 1.0f}, + {SOCK_RGBA,1,"Image", 1.0f, 1.0f, 1.0f, 1.0f}, + {SOCK_RGBA,1,"Key Color", 1.0f, 1.0f, 1.0f, 1.0f}, {-1,0,""} }; diff --git a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c index 6b833d44f72..c85a81b9bdb 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c @@ -37,7 +37,7 @@ /* ******************* Color Spill Supression ********************************* */ static bNodeSocketTemplate cmp_node_color_spill_in[]={ - {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f}, + {SOCK_RGBA,1,"Image", 1.0f, 1.0f, 1.0f, 1.0f}, {SOCK_FLOAT, 1, "Fac", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, {-1,0,""} }; diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c index e9176db4c0d..eb75802c0a6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c @@ -37,7 +37,7 @@ /* ******************* Color Balance ********************************* */ static bNodeSocketTemplate cmp_node_colorbalance_in[]={ {SOCK_FLOAT, 1, "Fac", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f}, + {SOCK_RGBA,1,"Image", 1.0f, 1.0f, 1.0f, 1.0f}, {-1,0,""} }; diff --git a/source/blender/nodes/composite/nodes/node_composite_crop.c b/source/blender/nodes/composite/nodes/node_composite_crop.c index c20593726cc..7847726c68e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_crop.c +++ b/source/blender/nodes/composite/nodes/node_composite_crop.c @@ -35,7 +35,7 @@ /* **************** Crop ******************** */ static bNodeSocketTemplate cmp_node_crop_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_crop_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.c b/source/blender/nodes/composite/nodes/node_composite_curves.c index c796a01f5a8..675710942fb 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.c +++ b/source/blender/nodes/composite/nodes/node_composite_curves.c @@ -121,7 +121,7 @@ void register_node_type_cmp_curve_vec(ListBase *lb) /* **************** CURVE RGB ******************** */ static bNodeSocketTemplate cmp_node_curve_rgb_in[]= { { SOCK_FLOAT, 1, "Fac", 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_FACTOR}, - { SOCK_RGBA, 1, "Image", 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_RGBA, 1, "Black Level", 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_RGBA, 1, "White Level", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c index 72a9897188c..2232c4a489e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_defocus.c +++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c @@ -34,8 +34,8 @@ /* ************ qdn: Defocus node ****************** */ static bNodeSocketTemplate cmp_node_defocus_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, - { SOCK_FLOAT, 1, "Z", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, + { SOCK_FLOAT, 1, "Z", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_defocus_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c index 8b1647414da..c621d524044 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c @@ -34,8 +34,8 @@ /* ******************* channel Difference Matte ********************************* */ static bNodeSocketTemplate cmp_node_diff_matte_in[]={ - {SOCK_RGBA,1,"Image 1", 0.8f, 0.8f, 0.8f, 1.0f}, - {SOCK_RGBA,1,"Image 2", 0.8f, 0.8f, 0.8f, 1.0f}, + {SOCK_RGBA,1,"Image 1", 1.0f, 1.0f, 1.0f, 1.0f}, + {SOCK_RGBA,1,"Image 2", 1.0f, 1.0f, 1.0f, 1.0f}, {-1,0,""} }; diff --git a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c index c77dc16bbf3..591870d0911 100644 --- a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c @@ -33,7 +33,7 @@ #include "node_composite_util.h" static bNodeSocketTemplate cmp_node_dblur_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_displace.c b/source/blender/nodes/composite/nodes/node_composite_displace.c index 8242acb6d49..02a1d203bef 100644 --- a/source/blender/nodes/composite/nodes/node_composite_displace.c +++ b/source/blender/nodes/composite/nodes/node_composite_displace.c @@ -36,7 +36,7 @@ /* **************** Displace ******************** */ static bNodeSocketTemplate cmp_node_displace_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_VECTOR, 1, "Vector", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_TRANSLATION}, { SOCK_FLOAT, 1, "X Scale", 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f, PROP_FACTOR}, { SOCK_FLOAT, 1, "Y Scale", 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f, PROP_FACTOR}, diff --git a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c index c4c6abbd718..401b143aac3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c @@ -34,8 +34,8 @@ /* ******************* channel Distance Matte ********************************* */ static bNodeSocketTemplate cmp_node_distance_matte_in[]={ - {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f}, - {SOCK_RGBA,1,"Key Color", 0.8f, 0.8f, 0.8f, 1.0f}, + {SOCK_RGBA,1,"Image", 1.0f, 1.0f, 1.0f, 1.0f}, + {SOCK_RGBA,1,"Key Color", 1.0f, 1.0f, 1.0f, 1.0f}, {-1,0,""} }; diff --git a/source/blender/nodes/composite/nodes/node_composite_filter.c b/source/blender/nodes/composite/nodes/node_composite_filter.c index 717942a0ec9..071ee84377c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_filter.c +++ b/source/blender/nodes/composite/nodes/node_composite_filter.c @@ -34,8 +34,8 @@ /* **************** FILTER ******************** */ static bNodeSocketTemplate cmp_node_filter_in[]= { - { SOCK_FLOAT, 1, "Fac", 1.0f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_FLOAT, 1, "Fac", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_filter_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_flip.c b/source/blender/nodes/composite/nodes/node_composite_flip.c index ba1b72a1fb4..01f58182227 100644 --- a/source/blender/nodes/composite/nodes/node_composite_flip.c +++ b/source/blender/nodes/composite/nodes/node_composite_flip.c @@ -34,7 +34,7 @@ /* **************** Flip ******************** */ static bNodeSocketTemplate cmp_node_flip_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_gamma.c b/source/blender/nodes/composite/nodes/node_composite_gamma.c index 1f8f934b1ba..2bb600db99d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_gamma.c +++ b/source/blender/nodes/composite/nodes/node_composite_gamma.c @@ -36,7 +36,7 @@ /* **************** Gamma Tools ******************** */ static bNodeSocketTemplate cmp_node_gamma_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, "Gamma", 1.0f, 0.0f, 0.0f, 0.0f, 0.001f, 10.0f, PROP_UNSIGNED}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.c b/source/blender/nodes/composite/nodes/node_composite_glare.c index 8660a4d612f..f4391a1af77 100644 --- a/source/blender/nodes/composite/nodes/node_composite_glare.c +++ b/source/blender/nodes/composite/nodes/node_composite_glare.c @@ -33,7 +33,7 @@ #include "node_composite_util.h" static bNodeSocketTemplate cmp_node_glare_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_glare_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c index a1c17abfdf6..c2304b37c0d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c +++ b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c @@ -36,7 +36,7 @@ /* **************** Hue Saturation ******************** */ static bNodeSocketTemplate cmp_node_hue_sat_in[]= { { SOCK_FLOAT, 1, "Fac", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_hue_sat_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c index 6b9196d58dc..f18eca3dfcc 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c @@ -34,7 +34,7 @@ static bNodeSocketTemplate cmp_node_huecorrect_in[]= { { SOCK_FLOAT, 1, "Fac", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, - { SOCK_RGBA, 1, "Image", 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_idMask.c b/source/blender/nodes/composite/nodes/node_composite_idMask.c index cf21efb000e..914483bc52f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_idMask.c +++ b/source/blender/nodes/composite/nodes/node_composite_idMask.c @@ -36,7 +36,7 @@ /* **************** ID Mask ******************** */ static bNodeSocketTemplate cmp_node_idmask_in[]= { - { SOCK_FLOAT, 1, "ID value", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f, PROP_NONE}, + { SOCK_FLOAT, 1, "ID value", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_idmask_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_invert.c b/source/blender/nodes/composite/nodes/node_composite_invert.c index 25ac24cf185..c428e37bd35 100644 --- a/source/blender/nodes/composite/nodes/node_composite_invert.c +++ b/source/blender/nodes/composite/nodes/node_composite_invert.c @@ -34,7 +34,7 @@ /* **************** INVERT ******************** */ static bNodeSocketTemplate cmp_node_invert_in[]= { { SOCK_FLOAT, 1, "Fac", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 1, "Color", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.c b/source/blender/nodes/composite/nodes/node_composite_lensdist.c index 4d2794d844d..e57f405ed68 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lensdist.c +++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.c @@ -33,7 +33,7 @@ #include "node_composite_util.h" static bNodeSocketTemplate cmp_node_lensdist_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, "Distort", 0.f, 0.f, 0.f, 0.f, -0.999f, 1.f, PROP_NONE}, { SOCK_FLOAT, 1, "Dispersion", 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, PROP_NONE}, { -1, 0, "" } diff --git a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c index 8c37b3dd90f..8573849b069 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c @@ -35,7 +35,7 @@ /* ******************* Luma Matte Node ********************************* */ static bNodeSocketTemplate cmp_node_luma_matte_in[]={ - {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f}, + {SOCK_RGBA,1,"Image", 1.0f, 1.0f, 1.0f, 1.0f}, {-1,0,""} }; diff --git a/source/blender/nodes/composite/nodes/node_composite_mapUV.c b/source/blender/nodes/composite/nodes/node_composite_mapUV.c index f4daf49f55d..5dc6d1c3aaa 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mapUV.c +++ b/source/blender/nodes/composite/nodes/node_composite_mapUV.c @@ -35,7 +35,7 @@ /* **************** Map UV ******************** */ static bNodeSocketTemplate cmp_node_mapuv_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_VECTOR, 1, "UV", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_mapValue.c b/source/blender/nodes/composite/nodes/node_composite_mapValue.c index 30eb0b8640b..81e963d4790 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mapValue.c +++ b/source/blender/nodes/composite/nodes/node_composite_mapValue.c @@ -34,7 +34,7 @@ /* **************** MAP VALUE ******************** */ static bNodeSocketTemplate cmp_node_map_value_in[]= { - { SOCK_FLOAT, 1, "Value", 1.0f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f, PROP_NONE}, + { SOCK_FLOAT, 1, "Value", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_map_value_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_normalize.c b/source/blender/nodes/composite/nodes/node_composite_normalize.c index a119a0b7de3..36206d82d0b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normalize.c +++ b/source/blender/nodes/composite/nodes/node_composite_normalize.c @@ -35,7 +35,7 @@ /* **************** NORMALIZE single channel, useful for Z buffer ******************** */ static bNodeSocketTemplate cmp_node_normalize_in[]= { - { SOCK_FLOAT, 1, "Value", 1.0f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f, PROP_NONE}, + { SOCK_FLOAT, 1, "Value", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_normalize_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_premulkey.c b/source/blender/nodes/composite/nodes/node_composite_premulkey.c index 7ce2f80e580..b188b0dd323 100644 --- a/source/blender/nodes/composite/nodes/node_composite_premulkey.c +++ b/source/blender/nodes/composite/nodes/node_composite_premulkey.c @@ -36,7 +36,7 @@ /* **************** Premul and Key Alpha Convert ******************** */ static bNodeSocketTemplate cmp_node_premulkey_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_premulkey_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_rgb.c b/source/blender/nodes/composite/nodes/node_composite_rgb.c index e86de3c7839..a7c820ddce6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_rgb.c @@ -35,7 +35,7 @@ /* **************** RGB ******************** */ static bNodeSocketTemplate cmp_node_rgb_out[]= { - { SOCK_RGBA, 0, "RGBA", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 0, "RGBA", 0.5f, 0.5f, 0.5f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_rotate.c b/source/blender/nodes/composite/nodes/node_composite_rotate.c index 74ab33eb093..96712baf8b0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rotate.c +++ b/source/blender/nodes/composite/nodes/node_composite_rotate.c @@ -35,7 +35,7 @@ /* **************** Rotate ******************** */ static bNodeSocketTemplate cmp_node_rotate_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, "Degr", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_ANGLE}, { -1, 0, "" } }; @@ -60,6 +60,7 @@ static void node_composit_exec_rotate(void *UNUSED(data), bNode *node, bNodeStac rad= (M_PI*in[1]->vec[0])/180.0f; + s= sin(rad); c= cos(rad); centx= cbuf->x/2; diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.c b/source/blender/nodes/composite/nodes/node_composite_scale.c index 48631a18dcb..5eb789ae0c9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_scale.c +++ b/source/blender/nodes/composite/nodes/node_composite_scale.c @@ -37,7 +37,7 @@ #define CMP_SCALE_MAX 12000 static bNodeSocketTemplate cmp_node_scale_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, "X", 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, CMP_SCALE_MAX, PROP_FACTOR}, { SOCK_FLOAT, 1, "Y", 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, CMP_SCALE_MAX, PROP_FACTOR}, { -1, 0, "" } diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c index 4a5036a6a7f..bf58d443aec 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c @@ -35,7 +35,7 @@ /* **************** SEPARATE HSVA ******************** */ static bNodeSocketTemplate cmp_node_sephsva_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_sephsva_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c index 143c67d099a..ade2b22bf35 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c @@ -34,7 +34,7 @@ /* **************** SEPARATE RGBA ******************** */ static bNodeSocketTemplate cmp_node_seprgba_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_seprgba_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c index 502d1999101..3b3d57bf442 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c @@ -35,7 +35,7 @@ /* **************** SEPARATE YCCA ******************** */ static bNodeSocketTemplate cmp_node_sepycca_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_sepycca_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c index 5a766df29ed..aedb5652e61 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c @@ -35,7 +35,7 @@ /* **************** SEPARATE YUVA ******************** */ static bNodeSocketTemplate cmp_node_sepyuva_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_sepyuva_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.c b/source/blender/nodes/composite/nodes/node_composite_tonemap.c index c243c104774..36e583a77ff 100644 --- a/source/blender/nodes/composite/nodes/node_composite_tonemap.c +++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.c @@ -33,7 +33,7 @@ #include "node_composite_util.h" static bNodeSocketTemplate cmp_node_tonemap_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_tonemap_out[]= { diff --git a/source/blender/nodes/composite/nodes/node_composite_translate.c b/source/blender/nodes/composite/nodes/node_composite_translate.c index 1865d6fc3d4..2b25ef92a1e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_translate.c +++ b/source/blender/nodes/composite/nodes/node_composite_translate.c @@ -36,7 +36,7 @@ /* **************** Translate ******************** */ static bNodeSocketTemplate cmp_node_translate_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, "X", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_NONE}, { SOCK_FLOAT, 1, "Y", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_NONE}, { -1, 0, "" } diff --git a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c index cdf56c230d8..a0fbcec198a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c +++ b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c @@ -35,7 +35,7 @@ /* **************** VECTOR BLUR ******************** */ static bNodeSocketTemplate cmp_node_vecblur_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, "Z", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE}, { SOCK_VECTOR, 1, "Speed", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_VELOCITY}, { -1, 0, "" } diff --git a/source/blender/nodes/composite/nodes/node_composite_zcombine.c b/source/blender/nodes/composite/nodes/node_composite_zcombine.c index 46a66957eac..7aac3539960 100644 --- a/source/blender/nodes/composite/nodes/node_composite_zcombine.c +++ b/source/blender/nodes/composite/nodes/node_composite_zcombine.c @@ -36,10 +36,10 @@ /* **************** Z COMBINE ******************** */ /* lazy coder note: node->custom2 is abused to send signal */ static bNodeSocketTemplate cmp_node_zcombine_in[]= { - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, - { SOCK_FLOAT, 1, "Z", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 10000.0f, PROP_NONE}, - { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, - { SOCK_FLOAT, 1, "Z", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 10000.0f, PROP_NONE}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, + { SOCK_FLOAT, 1, "Z", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 10000.0f, PROP_NONE}, + { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, + { SOCK_FLOAT, 1, "Z", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 10000.0f, PROP_NONE}, { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_zcombine_out[]= { diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 24d963243f6..03d66e918d5 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -1,5 +1,4 @@ -/* - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -21,20 +20,21 @@ * * This is a new part of Blender. * - * Contributor(s): Willian P. Germano + * Contributor(s): Willian P. Germano, Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/python/generic/bgl.c * \ingroup pygen + * + * This file is the 'bgl' module which wraps OpenGL functions and constants, + * allowing script writers to make OpenGL calls in their Python scripts. + * + * \note + * This module is very similar to 'PyOpenGL' which could replace 'bgl' one day. */ - -/* This file is the 'bgl' module. - * The BGL submodule "wraps" OpenGL functions and constants, - * allowing script writers to make OpenGL calls in their Python scripts. */ - #include <Python.h> #include "bgl.h" /*This must come first */ @@ -205,29 +205,36 @@ PyTypeObject BGL_bufferType = { NULL /*tp_del*/ }; - -/* #ifndef __APPLE__ */ - -#define BGL_Wrap(nargs, funcname, ret, arg_list) \ -static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\ - arg_def##nargs arg_list; \ - ret_def_##ret; \ - if (!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\ - ret_set_##ret gl##funcname (arg_var##nargs arg_list);\ - ret_ret_##ret; \ +#define BGL_Wrap(nargs, funcname, ret, arg_list) \ +static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) \ +{ \ + arg_def##nargs arg_list; \ + ret_def_##ret; \ + if (!PyArg_ParseTuple(args, \ + arg_str##nargs arg_list, \ + arg_ref##nargs arg_list)) \ + { \ + return NULL; \ + } \ + ret_set_##ret gl##funcname (arg_var##nargs arg_list); \ + ret_ret_##ret; \ } -#define BGLU_Wrap(nargs, funcname, ret, arg_list) \ -static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\ - arg_def##nargs arg_list; \ - ret_def_##ret; \ - if (!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\ - ret_set_##ret glu##funcname (arg_var##nargs arg_list);\ - ret_ret_##ret; \ +#define BGLU_Wrap(nargs, funcname, ret, arg_list) \ +static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) \ +{ \ + arg_def##nargs arg_list; \ + ret_def_##ret; \ + if (!PyArg_ParseTuple(args, \ + arg_str##nargs arg_list, \ + arg_ref##nargs arg_list)) \ + { \ + return NULL; \ + } \ + ret_set_##ret glu##funcname (arg_var##nargs arg_list); \ + ret_ret_##ret; \ } -/* #endif */ - /********/ int BGL_typeSize(int type) { @@ -267,7 +274,7 @@ Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuf memcpy(buffer->dimensions, dimensions, ndimensions*sizeof(int)); buffer->type= type; buffer->buf.asvoid= buf; - + if (initbuffer) { memcpy(buffer->buf.asvoid, initbuffer, length*size); } diff --git a/source/blender/python/generic/bgl.h b/source/blender/python/generic/bgl.h index 5cf9eac8289..2e02900d69f 100644 --- a/source/blender/python/generic/bgl.h +++ b/source/blender/python/generic/bgl.h @@ -1,5 +1,4 @@ -/* - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -331,12 +330,13 @@ extern PyTypeObject BGL_bufferType; #define ret_def_GLstring const unsigned char *ret_str; #define ret_set_GLstring ret_str= -#define ret_ret_GLstring \ - if (ret_str) {\ - return PyUnicode_FromString((const char *)ret_str);\ - } else {\ - PyErr_SetString(PyExc_AttributeError, "could not get opengl string");\ - return NULL;\ - } +#define ret_ret_GLstring \ + if (ret_str) { \ + return PyUnicode_FromString((const char *)ret_str); \ + } \ + else { \ + PyErr_SetString(PyExc_AttributeError, "could not get opengl string"); \ + return NULL; \ + } \ #endif /* BGL_H */ diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c index a9cd16c70f0..a4373e46e23 100644 --- a/source/blender/python/generic/blf_py_api.c +++ b/source/blender/python/generic/blf_py_api.c @@ -22,9 +22,10 @@ /** \file blender/python/generic/blf_py_api.c * \ingroup pygen + * + * This file defines the 'bgl' module, used for drawing text in OpenGL. */ - #include <Python.h> #include "blf_py_api.h" diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index 293ade35584..88e2da16eb5 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -15,18 +15,21 @@ * 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) 2001-2002 by NaN Holding BV. - * All rights reserved. - * * This is a new part of Blender. * - * Contributor(s): Willian P. Germano + * Contributor(s): Willian P. Germano, Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/python/generic/bpy_internal_import.c * \ingroup pygen + * + * This file defines replacements for pythons '__import__' and 'imp.reload' + * functions which can import from blender textblocks. + * + * \note + * This should eventually be replaced by import hooks (pep 302). */ @@ -308,77 +311,3 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module) PyMethodDef bpy_import_meth= {"bpy_import_meth", (PyCFunction)blender_import, METH_VARARGS | METH_KEYWORDS, "blenders import"}; PyMethodDef bpy_reload_meth= {"bpy_reload_meth", (PyCFunction)blender_reload, METH_O, "blenders reload"}; - - -/* Clear user modules. - * This is to clear any modules that could be defined from running scripts in blender. - * - * Its also needed for the BGE Python api so imported scripts are not used between levels - * - * This clears every modules that has a __file__ attribute (is not a builtin) - * - * Note that clearing external python modules is important for the BGE otherwise - * it wont reload scripts between loading different blend files or while making the game. - * - use 'clear_all' arg in this case. - * - * Since pythons built-ins include a full path even for win32. - * even if we remove a python module a re-import will bring it back again. - */ - -#if 0 // not used anymore but may still come in handy later - -#if defined(WIN32) || defined(WIN64) -#define SEPSTR "\\" -#else -#define SEPSTR "/" -#endif - - -void bpy_text_clear_modules(int clear_all) -{ - PyObject *modules= PyImport_GetModuleDict(); - - char *fname; - char *file_extension; - - /* looping over the dict */ - PyObject *key, *value; - Py_ssize_t pos= 0; - - /* new list */ - PyObject *list; - - if (modules==NULL) - return; /* should never happen but just incase */ - - list= PyList_New(0); - - /* go over sys.modules and remove anything with a - * sys.modukes[x].__file__ thats ends with a .py and has no path - */ - while (PyDict_Next(modules, &pos, &key, &value)) { - fname= PyModule_GetFilename(value); - if (fname) { - if (clear_all || ((strstr(fname, SEPSTR))==0)) { /* no path ? */ - file_extension= strstr(fname, ".py"); - if (file_extension && (*(file_extension + 3) == '\0' || *(file_extension + 4) == '\0')) { /* .py or pyc extension? */ - /* now we can be fairly sure its a python import from the blendfile */ - PyList_Append(list, key); /* free'd with the list */ - } - } - } - else { - PyErr_Clear(); - } - } - - /* remove all our modules */ - for (pos=0; pos < PyList_GET_SIZE(list); pos++) { - /* PyObject_Print(key, stderr, 0); */ - key= PyList_GET_ITEM(list, pos); - PyDict_DelItem(modules, key); - } - - Py_DECREF(list); /* removes all references from append */ -} -#endif diff --git a/source/blender/python/generic/noise_py_api.c b/source/blender/python/generic/noise_py_api.c index 6afb1a00e2f..c12cc1ccdd2 100644 --- a/source/blender/python/generic/noise_py_api.c +++ b/source/blender/python/generic/noise_py_api.c @@ -1,8 +1,4 @@ /* - * - * Blender.Noise BPython module implementation. - * This submodule has functions to generate noise of various types. - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -24,13 +20,16 @@ * * This is a new part of Blender. * - * Contributor(s): eeshlo + * Contributor(s): eeshlo, Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/python/generic/noise_py_api.c * \ingroup pygen + * + * This file defines the 'noise' module, a general purpose module to access + * blenders noise functions. */ diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index eb4ecf79941..7fbd8baa558 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -20,6 +20,13 @@ /** \file blender/python/generic/py_capi_utils.c * \ingroup pygen + * + * Extend upon CPython's API, filling in some gaps, these functions use PyC_ + * prefix to distinguish them apart from CPython. + * + * \note + * This module should only depend on CPython, however it currently uses + * BLI_string_utf8() for unicode conversion. */ diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index dfb7a1e8f75..2df907f3a12 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -22,11 +22,11 @@ /** \file blender/python/intern/bpy.c * \ingroup pythonintern + * + * This file defines the '_bpy' module which is used by python's 'bpy' package + * to access C defined builtin functions. + * A script writer should never directly access this module. */ - - -/* This file defines the '_bpy' module which is used by python's 'bpy' package. - * a script writer should never directly access this module */ #define WITH_PYTHON /* for AUD_PyInit.h, possibly others */ diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index cc3b88722b6..b5ae225fda7 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -22,6 +22,10 @@ /** \file blender/python/intern/bpy_app.c * \ingroup pythonintern + * + * This file defines a 'PyStructSequence' accessed via 'bpy.app', mostly + * exposing static applications variables such as version and buildinfo + * however some writable variables have been added such as 'debug' and 'tempdir' */ diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index 5b8c20bb12d..edab92b295b 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -22,6 +22,10 @@ /** \file blender/python/intern/bpy_app_handlers.c * \ingroup pythonintern + * + * This file defines a 'PyStructSequence' accessed via 'bpy.app.handlers', + * which exposes various lists that the script author can add callback + * functions into (called via blenders generic BLI_cb api) */ #include <Python.h> @@ -38,21 +42,21 @@ void bpy_app_generic_callback(struct Main *main, struct ID *id, void *arg); static PyTypeObject BlenderAppCbType; static PyStructSequence_Field app_cb_info_fields[]= { - {(char *)"frame_change_pre", NULL}, - {(char *)"frame_change_post", NULL}, - {(char *)"render_pre", NULL}, - {(char *)"render_post", NULL}, - {(char *)"render_stats", NULL}, - {(char *)"load_pre", NULL}, - {(char *)"load_post", NULL}, - {(char *)"save_pre", NULL}, - {(char *)"save_post", NULL}, - {(char *)"scene_update_pre", NULL}, - {(char *)"scene_update_post", NULL}, + {(char *)"frame_change_pre", (char *)"Callback list - on frame change for playback and rendering (before)"}, + {(char *)"frame_change_post", (char *)"Callback list - on frame change for playback and rendering (after)"}, + {(char *)"render_pre", (char *)"Callback list - on render (before)"}, + {(char *)"render_post", (char *)"Callback list - on render (after)"}, + {(char *)"render_stats", (char *)"Callback list - on printing render statistics"}, + {(char *)"load_pre", (char *)"Callback list - on loading a new blend file (before)"}, + {(char *)"load_post", (char *)"Callback list - on loading a new blend file (after)"}, + {(char *)"save_pre", (char *)"Callback list - on saving a blend file (before)"}, + {(char *)"save_post", (char *)"Callback list - on saving a blend file (after)"}, + {(char *)"scene_update_pre", (char *)"Callback list - on updating the scenes data (before)"}, + {(char *)"scene_update_post", (char *)"Callback list - on updating the scenes data (after)"}, /* sets the permanent tag */ # define APP_CB_OTHER_FIELDS 1 - {(char *)"persistent", NULL}, + {(char *)"persistent", (char *)"Function decorator for callback functions not to be removed when loading new files"}, {NULL} }; diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 0fe1d2d26ba..12fb5ed43b4 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -22,6 +22,10 @@ /** \file blender/python/intern/bpy_driver.c * \ingroup pythonintern + * + * This file defines the 'BPY_driver_exec' to execute python driver expressions, + * called by the animation system, there are also some utility functions + * to deal with the namespace used for driver execution. */ /* ****************************************** */ diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index ea2266c99b4..ffa9e5cc27c 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -23,6 +23,10 @@ /** \file blender/python/intern/bpy_interface.c * \ingroup pythonintern + * + * This file deals with embedding the python interpreter within blender, + * starting and stopping python and exposing blender/python modules so they can + * be accesses from scripts. */ diff --git a/source/blender/python/intern/bpy_interface_atexit.c b/source/blender/python/intern/bpy_interface_atexit.c index aa5b934891c..a0cf3c38503 100644 --- a/source/blender/python/intern/bpy_interface_atexit.c +++ b/source/blender/python/intern/bpy_interface_atexit.c @@ -22,6 +22,10 @@ /** \file blender/python/intern/bpy_interface_atexit.c * \ingroup pythonintern + * + * This file inserts an exit callback into pythons 'atexit' module. + * Without this sys.exit() can crash because blender is not properly closing + * resources. */ diff --git a/source/blender/python/intern/bpy_intern_string.c b/source/blender/python/intern/bpy_intern_string.c index 32d329e11b3..4f206c4c365 100644 --- a/source/blender/python/intern/bpy_intern_string.c +++ b/source/blender/python/intern/bpy_intern_string.c @@ -22,6 +22,10 @@ /** \file blender/python/intern/bpy_intern_string.c * \ingroup pythonintern + * + * Store python versions of strings frequently used for python lookups + * to avoid converting, creating the hash and freeing every time as + * PyDict_GetItemString and PyObject_GetAttrString do. */ #include <Python.h> diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c index 382a513f40a..b91948cc0b8 100644 --- a/source/blender/python/intern/bpy_library.c +++ b/source/blender/python/intern/bpy_library.c @@ -22,6 +22,13 @@ /** \file blender/python/intern/bpy_library.c * \ingroup pythonintern + * + * This file exposed blend file library appending/linking to python, typically + * this would be done via RNA api but in this case a hand written python api + * allows us to use pythons context manager (__enter__ and __exit__). + * + * Everything here is exposed via bpy.data.libraries.load(...) which returns + * a context manager. */ /* nifty feature. swap out strings for RNA data */ @@ -71,8 +78,8 @@ static PyObject *bpy_lib_dir(BPy_Library *self); static PyMethodDef bpy_lib_methods[]= { {"__enter__", (PyCFunction)bpy_lib_enter, METH_NOARGS}, - {"__exit__", (PyCFunction)bpy_lib_exit, METH_VARARGS}, - {"__dir__", (PyCFunction)bpy_lib_dir, METH_NOARGS}, + {"__exit__", (PyCFunction)bpy_lib_exit, METH_VARARGS}, + {"__dir__", (PyCFunction)bpy_lib_dir, METH_NOARGS}, {NULL} /* sentinel */ }; @@ -283,7 +290,7 @@ static void bpy_lib_exit_warn_idname(BPy_Library *self, const char *name_plural, PyObject *exc, *val, *tb; PyErr_Fetch(&exc, &val, &tb); if (PyErr_WarnFormat(PyExc_UserWarning, 1, - "load: '%s' does not contain %s[\"%s\"]", + "load: '%s' does not contain %s[\"%s\"]", self->abspath, name_plural, idname)) { /* Spurious errors can appear at shutdown */ if (PyErr_ExceptionMatches(PyExc_Warning)) { @@ -298,7 +305,7 @@ static void bpy_lib_exit_warn_type(BPy_Library *self, PyObject *item) PyObject *exc, *val, *tb; PyErr_Fetch(&exc, &val, &tb); if (PyErr_WarnFormat(PyExc_UserWarning, 1, - "load: '%s' expected a string type, not a %.200s", + "load: '%s' expected a string type, not a %.200s", self->abspath, Py_TYPE(item)->tp_name)) { /* Spurious errors can appear at shutdown */ if (PyErr_ExceptionMatches(PyExc_Warning)) { diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 70a5d79e9ac..3fd4e8a128b 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -1,6 +1,4 @@ - /* - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -24,6 +22,13 @@ /** \file blender/python/intern/bpy_operator.c * \ingroup pythonintern + * + * This file defines '_bpy.ops', an internal python module which gives python + * the ability to inspect and call both C and Python defined operators. + * + * \note + * This module is exposed to the user via 'release/scripts/modules/bpy/ops.py' + * which fakes exposing operators as modules/functions using its own classes. */ diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index cb460f2fa08..aa458925202 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -22,6 +22,11 @@ /** \file blender/python/intern/bpy_operator_wrap.c * \ingroup pythonintern + * + * This file is so python can define operators that C can call into. + * The generic callback functions for python operators are defines in + * 'rna_wm.c', some calling into functions here to do python specific + * functionality. */ diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index b10223207bf..4dbaf5db4a4 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -22,6 +22,10 @@ /** \file blender/python/intern/bpy_props.c * \ingroup pythonintern + * + * This file defines 'bpy.props' module used so scripts can define their own + * rna properties for use with python operators or adding new properties to + * existing blender types. */ @@ -254,7 +258,7 @@ static int bpy_prop_callback_assign(struct PropertyRNA *prop, PyObject *update_c { /* assume this is already checked for type and arg length */ if (update_cb) { - PyObject **py_data= MEM_callocN(sizeof(PyObject *) * BPY_DATA_CB_SLOT_SIZE, "bpy_prop_callback_assign"); + PyObject **py_data= MEM_callocN(sizeof(PyObject *) * BPY_DATA_CB_SLOT_SIZE, __func__); RNA_def_property_update_runtime(prop, (void *)bpy_prop_update_cb); py_data[BPY_DATA_CB_SLOT_UPDATE]= update_cb; RNA_def_py_data(prop, py_data); @@ -279,52 +283,60 @@ static int py_long_as_int(PyObject *py_long, int *r_int) /* this define runs at the start of each function and deals with * returning a deferred property (to be registered later) */ -#define BPY_PROPDEF_HEAD(_func) \ - if (PyTuple_GET_SIZE(args) == 1) { \ - PyObject *ret; \ - self= PyTuple_GET_ITEM(args, 0); \ - args= PyTuple_New(0); \ - ret= BPy_##_func(self, args, kw); \ - Py_DECREF(args); \ - return ret; \ - } \ - else if (PyTuple_GET_SIZE(args) > 1) { \ - PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \ - return NULL; \ - } \ - srna= srna_from_self(self, #_func"(...):"); \ - if (srna==NULL) { \ - if (PyErr_Occurred()) \ - return NULL; \ - return bpy_prop_deferred_return((void *)pymeth_##_func, kw); \ - } \ +#define BPY_PROPDEF_HEAD(_func) \ + if (PyTuple_GET_SIZE(args) == 1) { \ + PyObject *ret; \ + self= PyTuple_GET_ITEM(args, 0); \ + args= PyTuple_New(0); \ + ret= BPy_##_func(self, args, kw); \ + Py_DECREF(args); \ + return ret; \ + } \ + else if (PyTuple_GET_SIZE(args) > 1) { \ + PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \ + return NULL; \ + } \ + srna= srna_from_self(self, #_func"(...):"); \ + if (srna==NULL) { \ + if (PyErr_Occurred()) \ + return NULL; \ + return bpy_prop_deferred_return((void *)pymeth_##_func, kw); \ + } \ /* terse macros for error checks shared between all funcs cant use function * calls because of static strins passed to pyrna_set_to_enum_bitfield */ -#define BPY_PROPDEF_CHECK(_func, _property_flag_items) \ - if (id_len >= MAX_IDPROP_NAME) { \ - PyErr_Format(PyExc_TypeError, \ - #_func"(): '%.200s' too long, max length is %d", \ - id, MAX_IDPROP_NAME-1); \ - return NULL; \ - } \ - if (RNA_def_property_free_identifier(srna, id) == -1) { \ - PyErr_Format(PyExc_TypeError, \ - #_func"(): '%s' is defined as a non-dynamic type", \ - id); \ - return NULL; \ - } \ - if (pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, pyopts, &opts, #_func"(options={...}):")) \ - return NULL; \ - -#define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \ - BPY_PROPDEF_CHECK(_func, _property_flag_items) \ - if (pysubtype && RNA_enum_value_from_id(_subtype, pysubtype, &subtype)==0) { \ - PyErr_Format(PyExc_TypeError, \ - #_func"(subtype='%s'): invalid subtype", \ - pysubtype); \ - return NULL; \ - } \ +#define BPY_PROPDEF_CHECK(_func, _property_flag_items) \ + if (id_len >= MAX_IDPROP_NAME) { \ + PyErr_Format(PyExc_TypeError, \ + #_func"(): '%.200s' too long, max length is %d", \ + id, MAX_IDPROP_NAME-1); \ + return NULL; \ + } \ + if (RNA_def_property_free_identifier(srna, id) == -1) { \ + PyErr_Format(PyExc_TypeError, \ + #_func"(): '%s' is defined as a non-dynamic type", \ + id); \ + return NULL; \ + } \ + if (pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, \ + pyopts, \ + &opts, \ + #_func"(options={...}):")) \ + { \ + return NULL; \ + } \ + +#define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \ + BPY_PROPDEF_CHECK(_func, _property_flag_items) \ + if (pysubtype && RNA_enum_value_from_id(_subtype, \ + pysubtype, \ + &subtype)==0) \ + { \ + PyErr_Format(PyExc_TypeError, \ + #_func"(subtype='%s'): invalid subtype", \ + pysubtype); \ + return NULL; \ + } \ #define BPY_PROPDEF_NAME_DOC \ diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 1ecbeb4d16a..44e26a56db6 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -22,9 +22,14 @@ /** \file blender/python/intern/bpy_rna.c * \ingroup pythonintern + * + * This file is the main interface between python and blenders data api (RNA), + * exposing RNA to python so blender data can be accessed in a python like way. + * + * The two main types are 'BPy_StructRNA' and 'BPy_PropertyRNA' - the base + * classes for most of the data python accesses in blender. */ - #include <Python.h> #include <stddef.h> @@ -82,10 +87,10 @@ static PyObject* pyrna_struct_Subtype(PointerRNA *ptr); static PyObject *pyrna_prop_collection_values(BPy_PropertyRNA *self); -#define BPY_DOC_ID_PROP_TYPE_NOTE \ -" .. note::\n" \ -"\n" \ -" Only :class:`bpy.types.ID`, :class:`bpy.types.Bone` and \n" \ +#define BPY_DOC_ID_PROP_TYPE_NOTE \ +" .. note::\n" \ +"\n" \ +" Only :class:`bpy.types.ID`, :class:`bpy.types.Bone` and \n" \ " :class:`bpy.types.PoseBone` classes support custom properties.\n" @@ -6404,17 +6409,19 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun if (item==NULL) { /* Sneaky workaround to use the class name as the bl_idname */ -#define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \ - if (strcmp(identifier, rna_attr) == 0) { \ - item= PyObject_GetAttrString(py_class, py_attr); \ - if (item && item != Py_None) { \ - if (pyrna_py_to_prop(dummyptr, prop, NULL, item, "validating class:") != 0) { \ - Py_DECREF(item); \ - return -1; \ - } \ - } \ - Py_XDECREF(item); \ - } \ +#define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \ + if (strcmp(identifier, rna_attr) == 0) { \ + item= PyObject_GetAttrString(py_class, py_attr); \ + if (item && item != Py_None) { \ + if (pyrna_py_to_prop(dummyptr, prop, NULL, \ + item, "validating class:") != 0) \ + { \ + Py_DECREF(item); \ + return -1; \ + } \ + } \ + Py_XDECREF(item); \ + } \ BPY_REPLACEMENT_STRING("bl_idname", "__name__"); @@ -6468,7 +6475,9 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param const int is_operator= RNA_struct_is_a(ptr->type, &RNA_Operator); const char *func_id= RNA_function_identifier(func); /* testing, for correctness, not operator and not draw function */ - const short is_readonly= strstr("draw", func_id) || /*strstr("render", func_id) ||*/ !is_operator; + const short is_readonly= ((strncmp("draw", func_id, 4) ==0) || /* draw or draw_header */ + /*strstr("render", func_id) ||*/ + !is_operator); #endif py_class= RNA_struct_py_type_get(ptr->type); diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index 4ebb407f4d6..edc6e672238 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -22,6 +22,8 @@ /** \file blender/python/intern/bpy_rna_anim.c * \ingroup pythonintern + * + * This file defines the animation related methods used in bpy_rna.c */ #include <Python.h> diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c index eda2511a187..73e9e0a44d9 100644 --- a/source/blender/python/intern/bpy_rna_array.c +++ b/source/blender/python/intern/bpy_rna_array.c @@ -15,13 +15,15 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor(s): Arystanbek Dyussenov + * Contributor(s): Arystanbek Dyussenov, Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/python/intern/bpy_rna_array.c * \ingroup pythonintern + * + * This file deals with array access for 'BPy_PropertyArrayRNA' from bpy_rna.c */ #include <Python.h> diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c index af6fc88097b..85f950947a7 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.c @@ -22,6 +22,9 @@ /** \file blender/python/intern/bpy_rna_callback.c * \ingroup pythonintern + * + * This file currently exposes callbacks for interface regions but may be + * extended later. */ diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c index aa21627a279..5045f6708b5 100644 --- a/source/blender/python/intern/bpy_traceback.c +++ b/source/blender/python/intern/bpy_traceback.c @@ -20,6 +20,9 @@ /** \file blender/python/intern/bpy_traceback.c * \ingroup pythonintern + * + * This file contains utility functions for getting data from a python stack + * trace. */ diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index bec3a07d32a..fb42f7d59e0 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -22,9 +22,11 @@ /** \file blender/python/intern/bpy_util.c * \ingroup pythonintern + * + * This file contains blender/python utility functions for the api's internal + * use (unrelated to 'bpy.utils') */ - #include <Python.h> #include "bpy_util.h" diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c index 1162491ee26..57ce7b59067 100644 --- a/source/blender/python/intern/gpu.c +++ b/source/blender/python/intern/gpu.c @@ -27,6 +27,9 @@ /** \file blender/python/intern/gpu.c * \ingroup pythonintern + * + * This file defines the 'gpu' module, used to get GLSL shader code and data + * from blender materials. */ /* python redefines */ diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 770a743b733..41c1568dbde 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -25,8 +25,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils.c + * \ingroup pymathutils */ #include <Python.h> diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h index bcea62c8f1c..70b0ef93ebd 100644 --- a/source/blender/python/mathutils/mathutils.h +++ b/source/blender/python/mathutils/mathutils.h @@ -26,8 +26,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils.h + * \ingroup pymathutils */ //Include this file for access to vector, quat, matrix, euler, etc... diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index a0035e5f34d..c374d0eb73d 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -21,8 +21,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_Color.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Color.c + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Color.h b/source/blender/python/mathutils/mathutils_Color.h index 231fab511c8..6c84b5f596d 100644 --- a/source/blender/python/mathutils/mathutils_Color.h +++ b/source/blender/python/mathutils/mathutils_Color.h @@ -27,8 +27,8 @@ * */ -/** \file blender/python/generic/mathutils_Color.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Color.h + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 4d44ec8b1e9..ce9ac5fbbb5 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -25,8 +25,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_Euler.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Euler.c + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Euler.h b/source/blender/python/mathutils/mathutils_Euler.h index 0c51a2a1dd8..46f5910f31f 100644 --- a/source/blender/python/mathutils/mathutils_Euler.h +++ b/source/blender/python/mathutils/mathutils_Euler.h @@ -27,8 +27,8 @@ * */ -/** \file blender/python/generic/mathutils_Euler.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Euler.h + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 2a5d45bdff0..980dbd17a96 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -24,8 +24,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_Matrix.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Matrix.c + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h index 01fae91b1a4..275f4270787 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.h +++ b/source/blender/python/mathutils/mathutils_Matrix.h @@ -26,8 +26,8 @@ * */ -/** \file blender/python/generic/mathutils_Matrix.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Matrix.h + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index f892c25f67e..3f0a5d55ec2 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -24,8 +24,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_Quaternion.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Quaternion.c + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Quaternion.h b/source/blender/python/mathutils/mathutils_Quaternion.h index c8029d61679..13060ed9ff9 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.h +++ b/source/blender/python/mathutils/mathutils_Quaternion.h @@ -27,8 +27,8 @@ * */ -/** \file blender/python/generic/mathutils_Quaternion.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Quaternion.h + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index a932d8d6b01..ba7cf604c42 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -24,8 +24,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_Vector.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Vector.c + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Vector.h b/source/blender/python/mathutils/mathutils_Vector.h index bd4cd5f5be7..610805fcee0 100644 --- a/source/blender/python/mathutils/mathutils_Vector.h +++ b/source/blender/python/mathutils/mathutils_Vector.h @@ -27,8 +27,8 @@ * */ -/** \file blender/python/generic/mathutils_Vector.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Vector.h + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 6e8624721b7..e8721a3a91d 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -26,8 +26,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_geometry.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_geometry.c + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_geometry.h b/source/blender/python/mathutils/mathutils_geometry.h index 58a2bf9142f..1b339bdaf00 100644 --- a/source/blender/python/mathutils/mathutils_geometry.h +++ b/source/blender/python/mathutils/mathutils_geometry.h @@ -26,8 +26,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_geometry.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_geometry.h + * \ingroup pymathutils */ /*Include this file for access to vector, quat, matrix, euler, etc...*/ diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index ae4e55b9b88..7cad8c36df4 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -153,7 +153,9 @@ struct Render /* values for viewing */ float lens; + float sensor_x, sensor_y; /* image sensor size, same variable in camera */ float ycor; /* (scene->xasp / scene->yasp), multiplied with 'winy' */ + short sensor_fit; float panophi, panosi, panoco, panodxp, panodxv; diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h index 736f9e380aa..a702e890c3b 100644 --- a/source/blender/render/intern/include/texture.h +++ b/source/blender/render/intern/include/texture.h @@ -36,21 +36,26 @@ #ifndef TEXTURE_EXT_H #define TEXTURE_EXT_H -#define BRICONT texres->tin= (texres->tin-0.5f)*tex->contrast+tex->bright-0.5f; \ -if(texres->tin<0.0f) texres->tin= 0.0f; else if(texres->tin>1.0f) texres->tin= 1.0f; +#define BRICONT \ + texres->tin= (texres->tin-0.5f) * tex->contrast+tex->bright-0.5f; \ + if(texres->tin < 0.0f) texres->tin= 0.0f; \ + else if(texres->tin > 1.0f) texres->tin= 1.0f; \ -#define BRICONTRGB texres->tr= tex->rfac*((texres->tr-0.5f)*tex->contrast+tex->bright-0.5f); \ -if(texres->tr<0.0f) texres->tr= 0.0f; \ -texres->tg= tex->gfac*((texres->tg-0.5f)*tex->contrast+tex->bright-0.5f); \ -if(texres->tg<0.0f) texres->tg= 0.0f; \ -texres->tb= tex->bfac*((texres->tb-0.5f)*tex->contrast+tex->bright-0.5f); \ -if(texres->tb<0.0f) texres->tb= 0.0f; \ -if(tex->saturation != 1.0f) { \ - float _hsv[3]; \ - rgb_to_hsv(texres->tr, texres->tg, texres->tb, _hsv, _hsv+1, _hsv+2); \ - _hsv[1] *= tex->saturation; \ - hsv_to_rgb(_hsv[0], _hsv[1], _hsv[2], &texres->tr, &texres->tg, &texres->tb); \ -} \ +#define BRICONTRGB \ + texres->tr= tex->rfac*((texres->tr-0.5f)*tex->contrast+tex->bright-0.5f); \ + if(texres->tr<0.0f) texres->tr= 0.0f; \ + texres->tg= tex->gfac*((texres->tg-0.5f)*tex->contrast+tex->bright-0.5f); \ + if(texres->tg<0.0f) texres->tg= 0.0f; \ + texres->tb= tex->bfac*((texres->tb-0.5f)*tex->contrast+tex->bright-0.5f); \ + if(texres->tb<0.0f) texres->tb= 0.0f; \ + if(tex->saturation != 1.0f) { \ + float _hsv[3]; \ + rgb_to_hsv(texres->tr, texres->tg, texres->tb, \ + _hsv, _hsv+1, _hsv+2); \ + _hsv[1] *= tex->saturation; \ + hsv_to_rgb(_hsv[0], _hsv[1], _hsv[2], \ + &texres->tr, &texres->tg, &texres->tb); \ + } \ #define RGBTOBW(r,g,b) ( r*0.35f + g*0.45f + b*0.2f ) /* keep this in sync with gpu_shader_material.glsl:rgbtobw */ diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index e285b9b1ed9..2f20c328405 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -157,6 +157,7 @@ static Render *envmap_render_copy(Render *re, EnvMap *env) /* view stuff in env render */ envre->lens= 16.0f; + envre->sensor_x= 32.0f; if(env->type==ENV_PLANE) envre->lens*= env->viewscale; envre->ycor= 1.0f; diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index b37da67f743..b7f89e260a8 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -26,7 +26,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/render/intern/pipeline/engine.c +/** \file blender/render/intern/source/external_engine.c * \ingroup render */ diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 091a64e418e..7bd8dad6502 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -53,6 +53,7 @@ #include "DNA_scene_types.h" +#include "BKE_camera.h" #include "BKE_global.h" #include "BKE_material.h" #include "BKE_object.h" @@ -458,7 +459,7 @@ void RE_SetCamera(Render *re, Object *camera) object_camera_matrix(&re->r, camera, re->winx, re->winy, re->flag & R_SEC_FIELD, re->winmat, &re->viewplane, &re->clipsta, &re->clipend, - &re->lens, &re->ycor, &re->viewdx, &re->viewdy); + &re->lens, &re->sensor_x, &re->sensor_y, &re->sensor_fit, &re->ycor, &re->viewdx, &re->viewdy); } void RE_SetPixelSize(Render *re, float pixsize) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index de5d037675e..d4bd8f8a693 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -48,6 +48,7 @@ #include "MEM_guardedalloc.h" #include "BKE_animsys.h" /* <------ should this be here?, needed for sequencer update */ +#include "BKE_camera.h" #include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.h" diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 405ec082102..ebe53722ce1 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -213,24 +213,6 @@ void WM_init_splash(bContext *C) } } -static ScrArea *biggest_view3d(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) { - if(sa->spacetype==SPACE_VIEW3D) { - size= sa->winx * sa->winy; - if(size > maxsize) { - maxsize= size; - big= sa; - } - } - } - return big; -} - int WM_init_game(bContext *C) { wmWindowManager *wm= CTX_wm_manager(C); @@ -253,7 +235,7 @@ int WM_init_game(bContext *C) if(win) CTX_wm_window_set(C, win); - sa = biggest_view3d(C); + sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0); ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); // if we have a valid 3D view diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index acd5df79982..933066513e2 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3450,6 +3450,28 @@ static void WM_OT_memory_statistics(wmOperatorType *ot) ot->exec= memory_statistics_exec; } +/* ************************** memory statistics for testing ***************** */ + +static int dependency_relations_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_active_object(C); + + DAG_print_dependencies(bmain, scene, ob); + + return OPERATOR_FINISHED; +} + +static void WM_OT_dependency_relations(wmOperatorType *ot) +{ + ot->name= "Dependency Relations"; + ot->idname= "WM_OT_dependency_relations"; + ot->description= "Print dependency graph relations to the console"; + + ot->exec= dependency_relations_exec; +} + /* ******************************************************* */ static int wm_ndof_sensitivity_exec(bContext *UNUSED(C), wmOperator *op) @@ -3532,6 +3554,7 @@ void wm_operatortype_init(void) WM_operatortype_append(WM_OT_save_mainfile); WM_operatortype_append(WM_OT_redraw_timer); WM_operatortype_append(WM_OT_memory_statistics); + WM_operatortype_append(WM_OT_dependency_relations); WM_operatortype_append(WM_OT_debug_menu); WM_operatortype_append(WM_OT_splash); WM_operatortype_append(WM_OT_search_menu); diff --git a/source/creator/creator.c b/source/creator/creator.c index 2652868a9e5..c9b8b82054a 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -145,7 +145,9 @@ static int print_version(int argc, const char **argv, void *data); extern int pluginapi_force_ref(void); /* from blenpluginapi:pluginapi.c */ -#define BLEND_VERSION_STRING_FMT "Blender %d.%02d (sub %d)\n", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION +#define BLEND_VERSION_STRING_FMT \ + "Blender %d.%02d (sub %d)\n", \ + BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION \ /* Initialize callbacks for the modules that need them */ static void setCallbacks(void); @@ -880,22 +882,23 @@ static int set_skip_frame(int argc, const char **argv, void *data) /* macro for ugly context setup/reset */ #ifdef WITH_PYTHON -#define BPY_CTX_SETUP(_cmd) \ -{ \ - wmWindowManager *wm= CTX_wm_manager(C); \ - wmWindow *prevwin= CTX_wm_window(C); \ - Scene *prevscene= CTX_data_scene(C); \ - if(wm->windows.first) { \ - CTX_wm_window_set(C, wm->windows.first); \ - _cmd; \ - CTX_wm_window_set(C, prevwin); \ - } \ - else { \ - fprintf(stderr, "Python script \"%s\" running with missing context data.\n", argv[1]); \ - _cmd; \ - } \ - CTX_data_scene_set(C, prevscene); \ -} \ +#define BPY_CTX_SETUP(_cmd) \ +{ \ + wmWindowManager *wm= CTX_wm_manager(C); \ + wmWindow *prevwin= CTX_wm_window(C); \ + Scene *prevscene= CTX_data_scene(C); \ + if(wm->windows.first) { \ + CTX_wm_window_set(C, wm->windows.first); \ + _cmd; \ + CTX_wm_window_set(C, prevwin); \ + } \ + else { \ + fprintf(stderr, "Python script \"%s\" " \ + "running with missing context data.\n", argv[1]); \ + _cmd; \ + } \ + CTX_data_scene_set(C, prevscene); \ +} \ #endif /* WITH_PYTHON */ diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 2fb774dad44..29300281bb5 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -40,7 +40,7 @@ class BL_ActionActuator : public SCA_IActuator { public: - Py_Header; + Py_Header BL_ActionActuator(SCA_IObject* gameobj, const STR_String& propname, const STR_String& framepropname, @@ -70,8 +70,8 @@ public: #ifdef WITH_PYTHON - KX_PYMETHOD_O(BL_ActionActuator,GetChannel); - KX_PYMETHOD_DOC(BL_ActionActuator,setChannel); + KX_PYMETHOD_O(BL_ActionActuator,GetChannel) + KX_PYMETHOD_DOC(BL_ActionActuator,setChannel) static PyObject* pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); diff --git a/source/gameengine/Converter/BL_ArmatureActuator.h b/source/gameengine/Converter/BL_ArmatureActuator.h index 8390444613c..344b76ec278 100644 --- a/source/gameengine/Converter/BL_ArmatureActuator.h +++ b/source/gameengine/Converter/BL_ArmatureActuator.h @@ -46,7 +46,7 @@ class BL_ArmatureActuator : public SCA_IActuator { - Py_Header; + Py_Header public: BL_ArmatureActuator(SCA_IObject* gameobj, int type, diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.h b/source/gameengine/Converter/BL_ArmatureConstraint.h index 49a331e78a5..2abb36ff937 100644 --- a/source/gameengine/Converter/BL_ArmatureConstraint.h +++ b/source/gameengine/Converter/BL_ArmatureConstraint.h @@ -52,7 +52,7 @@ struct bPose; */ class BL_ArmatureConstraint : public PyObjectPlus { - Py_Header; + Py_Header private: struct bConstraint* m_constraint; diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index 9847558f708..745ffac0cb2 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -51,7 +51,7 @@ class KX_BlenderSceneConverter; class BL_ArmatureObject : public KX_GameObject { - Py_Header; + Py_Header public: double GetLastFrame (); diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index f79f33ccacd..95ae7591776 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1579,7 +1579,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, my_get_local_bounds(blenderobject,dm,objprop.m_boundobject.box.m_center,bb.m_extends); if (blenderobject->gameflag & OB_BOUNDS) { - switch (blenderobject->boundtype) + switch (blenderobject->collision_boundtype) { case OB_BOUND_BOX: objprop.m_boundclass = KX_BOUNDBOX; @@ -1648,7 +1648,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, } - objprop.m_concave = (blenderobject->boundtype & 4) != 0; + objprop.m_concave = (blenderobject->collision_boundtype == OB_BOUND_TRIANGLE_MESH); switch (physics_engine) { @@ -1724,7 +1724,7 @@ static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int l static KX_Camera *gamecamera_from_bcamera(Object *ob, KX_Scene *kxscene, KX_BlenderSceneConverter *converter) { Camera* ca = static_cast<Camera*>(ob->data); - RAS_CameraData camdata(ca->lens, ca->ortho_scale, ca->clipsta, ca->clipend, ca->type == CAM_PERSP, ca->YF_dofdist); + RAS_CameraData camdata(ca->lens, ca->ortho_scale, ca->sensor_x, ca->sensor_y, ca->sensor_fit, ca->clipsta, ca->clipend, ca->type == CAM_PERSP, ca->YF_dofdist); KX_Camera *gamecamera; gamecamera= new KX_Camera(kxscene, KX_Scene::m_callbacks, camdata); diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index c4251b3c503..90f44acb672 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -42,7 +42,7 @@ struct Key; class BL_ShapeActionActuator : public SCA_IActuator { public: - Py_Header; + Py_Header BL_ShapeActionActuator(SCA_IObject* gameobj, const STR_String& propname, const STR_String& framepropname, diff --git a/source/gameengine/Expressions/Expression.h b/source/gameengine/Expressions/Expression.h index 875bd758b68..b9232477c34 100644 --- a/source/gameengine/Expressions/Expression.h +++ b/source/gameengine/Expressions/Expression.h @@ -24,19 +24,25 @@ //extern int gRefCountExpr; // only for debugging purposes (detect mem.leaks) -#define PLUGIN_DECLARE_SERIAL_EXPRESSION(class_name,base_class_name) \ -public: \ - virtual base_class_name * Copy() { return new class_name; } \ - virtual bool EdSerialize(CompressorArchive& arch,class CFactoryManager* facmgr,bool bIsStoring); \ - virtual bool EdIdSerialize(CompressorArchive& arch,class CFactoryManager* facmgr,bool bIsStoring) \ -{ \ - if (bIsStoring) \ - { \ - unsigned char exprID = GetExpressionID(); \ - arch << exprID; \ - } \ - return true; \ -} \ +#define PLUGIN_DECLARE_SERIAL_EXPRESSION(class_name, base_class_name) \ +public: \ + virtual base_class_name * Copy() { \ + return new class_name; \ + } \ + virtual bool EdSerialize(CompressorArchive& arch, \ + class CFactoryManager* facmgr, \ + bool bIsStoring); \ + virtual bool EdIdSerialize(CompressorArchive& arch, \ + class CFactoryManager* facmgr, \ + bool bIsStoring) \ + { \ + if (bIsStoring) \ + { \ + unsigned char exprID = GetExpressionID(); \ + arch << exprID; \ + } \ + return true; \ + } \ diff --git a/source/gameengine/Expressions/ListValue.h b/source/gameengine/Expressions/ListValue.h index 76451215f82..26c11cccc7a 100644 --- a/source/gameengine/Expressions/ListValue.h +++ b/source/gameengine/Expressions/ListValue.h @@ -23,7 +23,7 @@ class CListValue : public CPropValue { - Py_Header; + Py_Header //PLUGIN_DECLARE_SERIAL (CListValue,CValue) public: @@ -58,7 +58,7 @@ public: void Resize(int num); void SetValue(int i,CValue* val); CValue* GetValue(int i){ assertd(i < m_pValueArray.size()); return m_pValueArray[i];} - int GetCount() { return m_pValueArray.size();}; + int GetCount() { return m_pValueArray.size(); } virtual const STR_String & GetText(); bool CheckEqual(CValue* first,CValue* second); diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index b05b7be0877..f263bf15f02 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -470,7 +470,7 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef * case KX_PYATTRIBUTE_TYPE_STRING: { STR_String *val = reinterpret_cast<STR_String*>(ptr); - return PyUnicode_FromString(*val); + return PyUnicode_From_STR_String(*val); } case KX_PYATTRIBUTE_TYPE_CHAR: { @@ -1042,8 +1042,8 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt else if (val_len > attrdef->m_imax) { // trim the string - *var = val; var->SetLength(attrdef->m_imax); + memcpy(var->Ptr(), val, attrdef->m_imax - 1); break; } } else if (val_len < attrdef->m_imin || val_len > attrdef->m_imax) @@ -1171,6 +1171,11 @@ PyObject *PyObjectPlus::NewProxyPlus_Ext(PyObjectPlus *self, PyTypeObject *tp, v return self->m_proxy; } +PyObject *PyUnicode_From_STR_String(const STR_String& str) +{ + return PyUnicode_FromStringAndSize(str.ReadPtr(), str.Length()); +} + /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// /* deprecation warning management */ diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 7ee4760c48d..3e1c54b0cc7 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -29,11 +29,12 @@ * \ingroup expressions */ +#ifndef _PY_OBJECT_PLUS_H +#define _PY_OBJECT_PLUS_H + /* for now keep weakrefs optional */ #define USE_WEAKREFS -#ifndef _adr_py_lib_h_ // only process once, -#define _adr_py_lib_h_ // even if multiply included #ifndef __cplusplus // c++ only #error Must be compiled with C++ @@ -45,10 +46,6 @@ #include "SG_QList.h" #include <stddef.h> -/*------------------------------ - * Python defines -------------------------------*/ - #ifdef WITH_PYTHON #ifdef USE_MATHUTILS extern "C" { @@ -69,26 +66,27 @@ typedef struct { void *link; } WarnLink; -#define ShowDeprecationWarning(old_way, new_way) \ -{ \ - static WarnLink wlink = {false, NULL}; \ - if ((m_ignore_deprecation_warnings || wlink.warn_done)==0) \ - { \ - ShowDeprecationWarning_func(old_way, new_way); \ - \ - WarnLink *wlink_last= GetDeprecationWarningLinkLast(); \ - wlink.warn_done = true; \ - wlink.link = NULL; \ - \ - if(wlink_last) { \ - wlink_last->link= (void *)&(wlink); \ - SetDeprecationWarningLinkLast(&(wlink)); \ - } else { \ - SetDeprecationWarningFirst(&(wlink)); \ - SetDeprecationWarningLinkLast(&(wlink)); \ - } \ - } \ -} \ +#define ShowDeprecationWarning(old_way, new_way) \ +{ \ + static WarnLink wlink = {false, NULL}; \ + if ((m_ignore_deprecation_warnings || wlink.warn_done)==0) \ + { \ + ShowDeprecationWarning_func(old_way, new_way); \ + \ + WarnLink *wlink_last= GetDeprecationWarningLinkLast(); \ + wlink.warn_done = true; \ + wlink.link = NULL; \ + \ + if(wlink_last) { \ + wlink_last->link= (void *)&(wlink); \ + SetDeprecationWarningLinkLast(&(wlink)); \ + } \ + else { \ + SetDeprecationWarningFirst(&(wlink)); \ + SetDeprecationWarningLinkLast(&(wlink)); \ + } \ + } \ +} \ @@ -109,7 +107,7 @@ typedef struct PyObjectPlus_Proxy { #define BGE_PROXY_PYOWNS(_self) (((PyObjectPlus_Proxy *)_self)->py_owns) #define BGE_PROXY_PYREF(_self) (((PyObjectPlus_Proxy *)_self)->py_ref) #ifdef USE_WEAKREFS - #define BGE_PROXY_WKREF(_self) (((PyObjectPlus_Proxy *)_self)->in_weakreflist) +# define BGE_PROXY_WKREF(_self) (((PyObjectPlus_Proxy *)_self)->in_weakreflist) #endif /* Note, sometimes we dont care what BGE type this is as long as its a proxy */ @@ -123,45 +121,61 @@ typedef struct PyObjectPlus_Proxy { // PyC++ class // AttributesPtr correspond to attributes of proxy generic pointer // each PyC++ class must be registered in KX_PythonInitTypes.cpp -#define __Py_Header \ - public: \ - static PyTypeObject Type; \ - static PyMethodDef Methods[]; \ - static PyAttributeDef Attributes[]; \ - virtual PyTypeObject *GetType(void) {return &Type;}; \ - virtual PyObject *GetProxy() {return GetProxyPlus_Ext(this, &Type, NULL);}; \ - virtual PyObject *NewProxy(bool py_owns) {return NewProxyPlus_Ext(this, &Type, NULL, py_owns);}; \ +#define __Py_Header \ +public: \ + static PyTypeObject Type; \ + static PyMethodDef Methods[]; \ + static PyAttributeDef Attributes[]; \ + virtual PyTypeObject *GetType(void) { \ + return &Type; \ + } \ + virtual PyObject *GetProxy() { \ + return GetProxyPlus_Ext(this, &Type, NULL); \ + } \ + virtual PyObject *NewProxy(bool py_owns) { \ + return NewProxyPlus_Ext(this, &Type, NULL, py_owns); \ + } \ // leave above line empty (macro)! // use this macro for class that use generic pointer in proxy // GetProxy() and NewProxy() must be defined to set the correct pointer in the proxy -#define __Py_HeaderPtr \ - public: \ - static PyTypeObject Type; \ - static PyMethodDef Methods[]; \ - static PyAttributeDef Attributes[]; \ - static PyAttributeDef AttributesPtr[]; \ - virtual PyTypeObject *GetType(void) {return &Type;}; \ - virtual PyObject *GetProxy(); \ - virtual PyObject *NewProxy(bool py_owns); \ +#define __Py_HeaderPtr \ +public: \ + static PyTypeObject Type; \ + static PyMethodDef Methods[]; \ + static PyAttributeDef Attributes[]; \ + static PyAttributeDef AttributesPtr[]; \ + virtual PyTypeObject *GetType(void) { \ + return &Type; \ + } \ + virtual PyObject *GetProxy(); \ + virtual PyObject *NewProxy(bool py_owns); \ // leave above line empty (macro)! #ifdef WITH_CXX_GUARDEDALLOC -#define Py_Header __Py_Header \ - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, Type.tp_name); } \ - void operator delete(void *mem) { MEM_freeN(mem); } \ +#define Py_Header __Py_Header \ + void *operator new(size_t num_bytes) { \ + return MEM_mallocN(num_bytes, Type.tp_name); \ + } \ + void operator delete(void *mem) { \ + MEM_freeN(mem); \ + } \ #else -#define Py_Header __Py_Header +# define Py_Header __Py_Header #endif #ifdef WITH_CXX_GUARDEDALLOC -#define Py_HeaderPtr __Py_HeaderPtr \ - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, Type.tp_name); } \ - void operator delete( void *mem ) { MEM_freeN(mem); } \ +#define Py_HeaderPtr __Py_HeaderPtr \ + void *operator new(size_t num_bytes) { \ + return MEM_mallocN(num_bytes, Type.tp_name); \ + } \ + void operator delete( void *mem ) { \ + MEM_freeN(mem); \ + } \ #else -#define Py_HeaderPtr __Py_HeaderPtr +# define Py_HeaderPtr __Py_HeaderPtr #endif /* @@ -179,65 +193,109 @@ typedef struct PyObjectPlus_Proxy { * These macros are helpfull when embedding Python routines. The second * macro is one that also requires a documentation string */ -#define KX_PYMETHOD(class_name, method_name) \ - PyObject* Py##method_name(PyObject* args, PyObject* kwds); \ - static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \ - if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \ - return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \ - }; \ - -#define KX_PYMETHOD_VARARGS(class_name, method_name) \ - PyObject* Py##method_name(PyObject* args); \ - static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \ - if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \ - return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args); \ - }; \ - -#define KX_PYMETHOD_NOARGS(class_name, method_name) \ - PyObject* Py##method_name(); \ - static PyObject* sPy##method_name( PyObject* self) { \ - if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \ - return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(); \ - }; \ - -#define KX_PYMETHOD_O(class_name, method_name) \ - PyObject* Py##method_name(PyObject* value); \ - static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \ - if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "(value) - " BGE_PROXY_ERROR_MSG); return NULL; } \ - return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value); \ - }; \ - -#define KX_PYMETHOD_DOC(class_name, method_name) \ - PyObject* Py##method_name(PyObject* args, PyObject* kwds); \ - static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \ - if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "(...) - " BGE_PROXY_ERROR_MSG); return NULL; } \ - return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \ - }; \ - static const char method_name##_doc[]; \ - -#define KX_PYMETHOD_DOC_VARARGS(class_name, method_name) \ - PyObject* Py##method_name(PyObject* args); \ - static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \ - if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "(...) - " BGE_PROXY_ERROR_MSG); return NULL; } \ - return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args); \ - }; \ - static const char method_name##_doc[]; \ - -#define KX_PYMETHOD_DOC_O(class_name, method_name) \ - PyObject* Py##method_name(PyObject* value); \ - static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \ - if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "(value) - " BGE_PROXY_ERROR_MSG); return NULL; } \ - return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value); \ - }; \ - static const char method_name##_doc[]; \ - -#define KX_PYMETHOD_DOC_NOARGS(class_name, method_name) \ - PyObject* Py##method_name(); \ - static PyObject* sPy##method_name( PyObject* self) { \ - if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \ - return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(); \ - }; \ - static const char method_name##_doc[]; \ +#define KX_PYMETHOD(class_name, method_name) \ + PyObject* Py##method_name(PyObject* args, PyObject* kwds); \ + static PyObject* \ + sPy##method_name(PyObject* self, PyObject* args, PyObject* kwds) { \ + if(BGE_PROXY_REF(self)==NULL) { \ + PyErr_SetString(PyExc_RuntimeError, \ + #class_name "." #method_name "() - " \ + BGE_PROXY_ERROR_MSG); \ + return NULL; \ + } \ + return((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \ + } \ + +#define KX_PYMETHOD_VARARGS(class_name, method_name) \ + PyObject* Py##method_name(PyObject* args); \ + static PyObject* \ + sPy##method_name(PyObject* self, PyObject* args) { \ + if(BGE_PROXY_REF(self)==NULL) { \ + PyErr_SetString(PyExc_RuntimeError, \ + #class_name "." #method_name "() - " \ + BGE_PROXY_ERROR_MSG); return NULL; \ + } \ + return((class_name*)BGE_PROXY_REF(self))->Py##method_name(args); \ + } \ + +#define KX_PYMETHOD_NOARGS(class_name, method_name) \ + PyObject* Py##method_name(); \ + static PyObject* \ + sPy##method_name(PyObject* self) { \ + if(BGE_PROXY_REF(self)==NULL) { \ + PyErr_SetString(PyExc_RuntimeError, \ + #class_name "." #method_name "() - " \ + BGE_PROXY_ERROR_MSG); return NULL; \ + } \ + return((class_name*)BGE_PROXY_REF(self))->Py##method_name(); \ + } \ + +#define KX_PYMETHOD_O(class_name, method_name) \ + PyObject* Py##method_name(PyObject* value); \ + static PyObject* \ + sPy##method_name(PyObject* self, PyObject* value) { \ + if(BGE_PROXY_REF(self)==NULL) { \ + PyErr_SetString(PyExc_RuntimeError, \ + #class_name "." #method_name "(value) - " \ + BGE_PROXY_ERROR_MSG); return NULL; \ + } \ + return((class_name*)BGE_PROXY_REF(self))->Py##method_name(value); \ + } \ + +#define KX_PYMETHOD_DOC(class_name, method_name) \ + PyObject* Py##method_name(PyObject* args, PyObject* kwds); \ + static PyObject* \ + sPy##method_name(PyObject* self, PyObject* args, PyObject* kwds) { \ + if(BGE_PROXY_REF(self)==NULL) { \ + PyErr_SetString(PyExc_RuntimeError, \ + #class_name "." #method_name "(...) - " \ + BGE_PROXY_ERROR_MSG); return NULL; \ + } \ + return((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \ + } \ + static const char method_name##_doc[]; \ + +#define KX_PYMETHOD_DOC_VARARGS(class_name, method_name) \ + PyObject* Py##method_name(PyObject* args); \ + static PyObject* \ + sPy##method_name(PyObject* self, PyObject* args) { \ + if(BGE_PROXY_REF(self)==NULL) { \ + PyErr_SetString(PyExc_RuntimeError, \ + #class_name "." #method_name "(...) - " \ + BGE_PROXY_ERROR_MSG); \ + return NULL; \ + } \ + return((class_name*)BGE_PROXY_REF(self))->Py##method_name(args); \ + } \ + static const char method_name##_doc[]; \ + +#define KX_PYMETHOD_DOC_O(class_name, method_name) \ + PyObject* Py##method_name(PyObject* value); \ + static PyObject* \ + sPy##method_name(PyObject* self, PyObject* value) { \ + if(BGE_PROXY_REF(self)==NULL) { \ + PyErr_SetString(PyExc_RuntimeError, \ + #class_name "." #method_name "(value) - " \ + BGE_PROXY_ERROR_MSG); \ + return NULL; \ + } \ + return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value); \ + } \ + static const char method_name##_doc[]; \ + +#define KX_PYMETHOD_DOC_NOARGS(class_name, method_name) \ + PyObject* Py##method_name(); \ + static PyObject* \ + sPy##method_name(PyObject* self) { \ + if(BGE_PROXY_REF(self)==NULL) { \ + PyErr_SetString(PyExc_RuntimeError, \ + #class_name "." #method_name "() - " \ + BGE_PROXY_ERROR_MSG); \ + return NULL; \ + } \ + return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(); \ + } \ + static const char method_name##_doc[]; \ /* The line above should remain empty */ @@ -289,7 +347,7 @@ enum KX_PYATTRIBUTE_TYPE { KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_TYPE_VECTOR, KX_PYATTRIBUTE_TYPE_FLAG, - KX_PYATTRIBUTE_TYPE_CHAR, + KX_PYATTRIBUTE_TYPE_CHAR }; enum KX_PYATTRIBUTE_ACCESS { @@ -478,23 +536,31 @@ typedef PyTypeObject * PyParentObject; // Define the PyParent Object #else // WITH_PYTHON #ifdef WITH_CXX_GUARDEDALLOC -#define Py_Header \ - public: \ - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:PyObjectPlus"); } \ - void operator delete( void *mem ) { MEM_freeN(mem); } \ - -#define Py_HeaderPtr \ - public: \ - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:PyObjectPlusPtr"); } \ - void operator delete( void *mem ) { MEM_freeN(mem); } \ +#define Py_Header \ +public: \ + void *operator new(size_t num_bytes) { \ + return MEM_mallocN(num_bytes, "GE:PyObjectPlus"); \ + } \ + void operator delete( void *mem ) { \ + MEM_freeN(mem); \ + } \ + +#define Py_HeaderPtr \ +public: \ + void *operator new(size_t num_bytes) { \ + return MEM_mallocN(num_bytes, "GE:PyObjectPlusPtr"); \ + } \ + void operator delete( void *mem ) { \ + MEM_freeN(mem); \ + } \ #else // WITH_CXX_GUARDEDALLOC #define Py_Header \ - public: \ +public: \ #define Py_HeaderPtr \ - public: \ +public: \ #endif // WITH_CXX_GUARDEDALLOC @@ -514,7 +580,7 @@ typedef PyTypeObject * PyParentObject; // Define the PyParent Object // possibility to use them at SCA_ILogicBrick, CValue and PyObjectPlus level. class PyObjectPlus : public SG_QList { // The PyObjectPlus abstract class - Py_Header; // Always start with Py_Header + Py_Header // Always start with Py_Header public: PyObjectPlus(); @@ -579,6 +645,8 @@ public: #ifdef WITH_PYTHON PyObject *py_getattr_dict(PyObject *pydict, PyObject *tp_dict); + +PyObject *PyUnicode_From_STR_String(const STR_String& str); #endif -#endif // _adr_py_lib_h_ +#endif // _PY_OBJECT_PLUS_H diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 41c0850a779..91fdbb0dabc 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -532,7 +532,7 @@ PyAttributeDef CValue::Attributes[] = { PyObject * CValue::pyattr_get_name(void * self_v, const KX_PYATTRIBUTE_DEF * attrdef) { CValue * self = static_cast<CValue *> (self_v); - return PyUnicode_FromString(self->GetName()); + return PyUnicode_From_STR_String(self->GetName()); } CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix) @@ -596,22 +596,24 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix) } -PyObject* CValue::ConvertKeysToPython( void ) +PyObject* CValue::ConvertKeysToPython(void) { - PyObject *pylist = PyList_New( 0 ); - PyObject *pystr; - if (m_pNamedPropertyArray) { + PyObject *pylist= PyList_New(m_pNamedPropertyArray->size()); + Py_ssize_t i= 0; + std::map<STR_String,CValue*>::iterator it; for (it= m_pNamedPropertyArray->begin(); (it != m_pNamedPropertyArray->end()); it++) { - pystr = PyUnicode_FromString( (*it).first ); - PyList_Append(pylist, pystr); - Py_DECREF( pystr ); + PyList_SET_ITEM(pylist, i++, PyUnicode_From_STR_String((*it).first)); } + + return pylist; + } + else { + return PyList_New(0); } - return pylist; } #endif // WITH_PYTHON diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index 955e688ad7b..f9697a55d3f 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -200,7 +200,7 @@ public: class CValue : public PyObjectPlus { -Py_Header; +Py_Header public: enum AllocationTYPE { STACKVALUE = 0, @@ -319,7 +319,7 @@ public: virtual const STR_String & GetText() = 0; virtual double GetNumber() = 0; - double* ZeroVector() { return m_sZeroVec; }; + double* ZeroVector() { return m_sZeroVec; } virtual double* GetVector3(bool bGetTransformedVec = false); virtual STR_String& GetName() = 0; // Retrieve the name of the value @@ -348,11 +348,11 @@ public: virtual bool IsSelected() { return m_ValFlags.Selected; } inline bool IsReleaseRequested() { return m_ValFlags.ReleaseRequested; } virtual bool IsVisible() { return m_ValFlags.Visible;} - virtual void SetCustomFlag1(bool bCustomFlag) { m_ValFlags.CustomFlag1 = bCustomFlag;}; - virtual bool IsCustomFlag1() { return m_ValFlags.CustomFlag1;}; + virtual void SetCustomFlag1(bool bCustomFlag) { m_ValFlags.CustomFlag1 = bCustomFlag;} + virtual bool IsCustomFlag1() { return m_ValFlags.CustomFlag1;} - virtual void SetCustomFlag2(bool bCustomFlag) { m_ValFlags.CustomFlag2 = bCustomFlag;}; - virtual bool IsCustomFlag2() { return m_ValFlags.CustomFlag2;}; + virtual void SetCustomFlag2(bool bCustomFlag) { m_ValFlags.CustomFlag2 = bCustomFlag;} + virtual bool IsCustomFlag2() { return m_ValFlags.CustomFlag2;} protected: virtual void DisableRefCount(); // Disable reference counting for this value @@ -379,18 +379,23 @@ private: // of object. So, for *any* CValue-derived object this should be set to CValue, // for *any* CExpression-derived object this should be set to CExpression. // -#define PLUGIN_DECLARE_SERIAL(class_name, root_base_class_name) \ -public: \ - virtual root_base_class_name * Copy() { return new class_name; } \ - virtual bool EdSerialize(CompressorArchive& arch,class CFactoryManager* facmgr,bool bIsStoring); \ - virtual bool EdIdSerialize(CompressorArchive& arch,class CFactoryManager* facmgr,bool bIsStoring) \ -{ \ - if (bIsStoring) \ - arch.StoreString(#class_name); \ - \ - return false; \ -} \ - +#define PLUGIN_DECLARE_SERIAL(class_name, root_base_class_name) \ +public: \ + virtual root_base_class_name *Copy() { \ + return new class_name; \ + } \ + virtual bool EdSerialize(CompressorArchive& arch, \ + class CFactoryManager* facmgr, \ + bool bIsStoring); \ + virtual bool EdIdSerialize(CompressorArchive& arch, \ + class CFactoryManager* facmgr, \ + bool bIsStoring) \ + { \ + if (bIsStoring) \ + arch.StoreString(#class_name); \ + return false; \ + } \ + //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -424,7 +429,7 @@ public: //if (namefromprop.Length() > 0) // return namefromprop; return m_strNewName; - }; // name of Value + } // name of Value protected: STR_String m_strNewName; // Identification diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h index ec4c4a1cbcf..42446b7a2b1 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -37,7 +37,7 @@ class SCA_2DFilterActuator : public SCA_IActuator { - Py_Header; + Py_Header private: vector<STR_String> m_propNames; diff --git a/source/gameengine/GameLogic/SCA_ANDController.h b/source/gameengine/GameLogic/SCA_ANDController.h index e39dea547a2..363bca630aa 100644 --- a/source/gameengine/GameLogic/SCA_ANDController.h +++ b/source/gameengine/GameLogic/SCA_ANDController.h @@ -39,7 +39,7 @@ class SCA_ANDController : public SCA_IController { - Py_Header; + Py_Header //virtual void Trigger(class SCA_LogicManager* logicmgr); public: SCA_ANDController(SCA_IObject* gameobj); diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h index 9b5793787a2..e7a7525bb40 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h @@ -40,7 +40,7 @@ class SCA_ActuatorSensor : public SCA_ISensor { - Py_Header; + Py_Header STR_String m_checkactname; bool m_lastresult; bool m_midresult; diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.h b/source/gameengine/GameLogic/SCA_AlwaysSensor.h index 41e9a9612c6..8748793d9a3 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysSensor.h +++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.h @@ -38,7 +38,7 @@ class SCA_AlwaysSensor : public SCA_ISensor { - Py_Header; + Py_Header bool m_alwaysresult; public: SCA_AlwaysSensor(class SCA_EventManager* eventmgr, diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h index fea713502b4..ccb8f00c548 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.h +++ b/source/gameengine/GameLogic/SCA_DelaySensor.h @@ -38,7 +38,7 @@ class SCA_DelaySensor : public SCA_ISensor { - Py_Header; + Py_Header bool m_lastResult; bool m_repeat; int m_delay; diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.h b/source/gameengine/GameLogic/SCA_ExpressionController.h index 4e549c08ed1..93a3f08c95f 100644 --- a/source/gameengine/GameLogic/SCA_ExpressionController.h +++ b/source/gameengine/GameLogic/SCA_ExpressionController.h @@ -39,7 +39,7 @@ class SCA_ExpressionController : public SCA_IController { -// Py_Header; +// Py_Header STR_String m_exprText; CExpression* m_exprCache; diff --git a/source/gameengine/GameLogic/SCA_IController.h b/source/gameengine/GameLogic/SCA_IController.h index 795e02dcf78..5481f2ae8e4 100644 --- a/source/gameengine/GameLogic/SCA_IController.h +++ b/source/gameengine/GameLogic/SCA_IController.h @@ -42,7 +42,7 @@ */ class SCA_IController : public SCA_ILogicBrick { - Py_Header; + Py_Header protected: std::vector<class SCA_ISensor*> m_linkedsensors; std::vector<class SCA_IActuator*> m_linkedactuators; diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index 4016c557bf3..87b37a8ef39 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -43,7 +43,7 @@ class SCA_IScene; class SCA_ILogicBrick : public CValue { - Py_Header; + Py_Header protected: SCA_IObject* m_gameobj; int m_Execute_Priority; diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h index 1d16d4f0af7..b0a03de1242 100644 --- a/source/gameengine/GameLogic/SCA_IObject.h +++ b/source/gameengine/GameLogic/SCA_IObject.h @@ -54,7 +54,7 @@ typedef std::vector<SCA_IObject *> SCA_ObjectList; class SCA_IObject : public CValue { - Py_Header; + Py_Header protected: friend class KX_StateActuator; diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 970faf7d29a..ef082095c0d 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -47,7 +47,7 @@ */ class SCA_ISensor : public SCA_ILogicBrick { - Py_Header; + Py_Header protected: class SCA_EventManager* m_eventmgr; diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index b4ed2c06d2f..db34ce4cc15 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -38,7 +38,7 @@ class SCA_JoystickSensor :public SCA_ISensor { - Py_Header; + Py_Header /** * Axis 1-JOYAXIS_MAX, MUST be followed by m_axisf @@ -128,8 +128,8 @@ public: /* --------------------------------------------------------------------- */ /* Joystick Index */ - KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButtonActiveList); - KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,GetButtonStatus); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButtonActiveList) + KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,GetButtonStatus) static PyObject* pyattr_get_axis_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_axis_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h index 37a42cdcbe6..e7283978ae1 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h @@ -44,7 +44,7 @@ * exclusive. */ class SCA_KeyboardSensor : public SCA_ISensor { - Py_Header; + Py_Header /** * the key this sensor is sensing for diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h index ecfa776112a..4bac9c10e13 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.h +++ b/source/gameengine/GameLogic/SCA_MouseSensor.h @@ -39,7 +39,7 @@ class SCA_MouseSensor : public SCA_ISensor { - Py_Header; + Py_Header /** * Use SCA_IInputDevice values to encode the mouse mode for now. diff --git a/source/gameengine/GameLogic/SCA_NANDController.h b/source/gameengine/GameLogic/SCA_NANDController.h index 8eb26127a51..723d2a5fe0d 100644 --- a/source/gameengine/GameLogic/SCA_NANDController.h +++ b/source/gameengine/GameLogic/SCA_NANDController.h @@ -36,7 +36,7 @@ class SCA_NANDController : public SCA_IController { - Py_Header; + Py_Header //virtual void Trigger(class SCA_LogicManager* logicmgr); public: SCA_NANDController(SCA_IObject* gameobj); diff --git a/source/gameengine/GameLogic/SCA_NORController.h b/source/gameengine/GameLogic/SCA_NORController.h index 6580ad7bc8c..26d7e925923 100644 --- a/source/gameengine/GameLogic/SCA_NORController.h +++ b/source/gameengine/GameLogic/SCA_NORController.h @@ -36,7 +36,7 @@ class SCA_NORController : public SCA_IController { - Py_Header; + Py_Header //virtual void Trigger(class SCA_LogicManager* logicmgr); public: SCA_NORController(SCA_IObject* gameobj); diff --git a/source/gameengine/GameLogic/SCA_ORController.h b/source/gameengine/GameLogic/SCA_ORController.h index 4edd34f6302..53debf894a3 100644 --- a/source/gameengine/GameLogic/SCA_ORController.h +++ b/source/gameengine/GameLogic/SCA_ORController.h @@ -36,7 +36,7 @@ class SCA_ORController : public SCA_IController { - Py_Header; + Py_Header //virtual void Trigger(class SCA_LogicManager* logicmgr); public: SCA_ORController(SCA_IObject* gameobj); diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h index f4a43a7e21c..17419e34c2a 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.h +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h @@ -36,7 +36,7 @@ class SCA_PropertyActuator : public SCA_IActuator { - Py_Header; + Py_Header enum KX_ACT_PROP_MODE { KX_ACT_PROP_NODEF = 0, diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h index c1fe5320546..bf7b1e879f7 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.h +++ b/source/gameengine/GameLogic/SCA_PropertySensor.h @@ -37,7 +37,7 @@ class SCA_PropertySensor : public SCA_ISensor { - Py_Header; + Py_Header //class CExpression* m_rightexpr; int m_checktype; STR_String m_checkpropval; diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index d69358928e6..8a87a734a1c 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -164,7 +164,7 @@ void SCA_PythonController::SetNamespace(PyObject* pythondictionary) /* Without __file__ set the sys.argv[0] is used for the filename * which ends up with lines from the blender binary being printed in the console */ - PyDict_SetItemString(m_pythondictionary, "__file__", PyUnicode_FromString(m_scriptName.Ptr())); + PyDict_SetItemString(m_pythondictionary, "__file__", PyUnicode_From_STR_String(m_scriptName)); } #endif @@ -490,7 +490,7 @@ PyObject* SCA_PythonController::pyattr_get_script(void *self_v, const KX_PYATTRI // static_cast<void *>(dynamic_cast<Derived *>(obj)) - static_cast<void *>(obj) SCA_PythonController* self= static_cast<SCA_PythonController*>(self_v); - return PyUnicode_FromString(self->m_scriptText); + return PyUnicode_From_STR_String(self->m_scriptText); } diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index 0d22c347861..521a676bf4a 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -42,7 +42,7 @@ class SCA_IObject; class SCA_PythonController : public SCA_IController { - Py_Header; + Py_Header #ifdef WITH_PYTHON struct _object * m_bytecode; /* SCA_PYEXEC_SCRIPT only */ PyObject* m_function; /* SCA_PYEXEC_MODULE only */ diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.h b/source/gameengine/GameLogic/SCA_PythonKeyboard.h index 9c761e054f2..7ecf76d1581 100644 --- a/source/gameengine/GameLogic/SCA_PythonKeyboard.h +++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.h @@ -31,7 +31,7 @@ class SCA_PythonKeyboard : public PyObjectPlus { - Py_Header; + Py_Header private: class SCA_IInputDevice *m_keyboard; #ifdef WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.h b/source/gameengine/GameLogic/SCA_PythonMouse.h index dfdf00bc6e9..4ad655dce8f 100644 --- a/source/gameengine/GameLogic/SCA_PythonMouse.h +++ b/source/gameengine/GameLogic/SCA_PythonMouse.h @@ -31,7 +31,7 @@ class SCA_PythonMouse : public PyObjectPlus { - Py_Header; + Py_Header private: class SCA_IInputDevice *m_mouse; class RAS_ICanvas *m_canvas; diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h index 66d22d5952b..c439b445a5b 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.h +++ b/source/gameengine/GameLogic/SCA_RandomActuator.h @@ -38,7 +38,7 @@ class SCA_RandomActuator : public SCA_IActuator { - Py_Header; + Py_Header /** Property to assign to */ STR_String m_propname; diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h index f0ae2fd2bde..cec8bcdb445 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.h +++ b/source/gameengine/GameLogic/SCA_RandomSensor.h @@ -39,7 +39,7 @@ class SCA_RandomSensor : public SCA_ISensor { - Py_Header; + Py_Header unsigned int m_currentDraw; int m_iteration; diff --git a/source/gameengine/GameLogic/SCA_XNORController.h b/source/gameengine/GameLogic/SCA_XNORController.h index de0af2ba9d5..c2cdad2cdf4 100644 --- a/source/gameengine/GameLogic/SCA_XNORController.h +++ b/source/gameengine/GameLogic/SCA_XNORController.h @@ -36,7 +36,7 @@ class SCA_XNORController : public SCA_IController { - Py_Header; + Py_Header //virtual void Trigger(class SCA_LogicManager* logicmgr); public: SCA_XNORController(SCA_IObject* gameobj); diff --git a/source/gameengine/GameLogic/SCA_XORController.h b/source/gameengine/GameLogic/SCA_XORController.h index 96098082165..1f38a510046 100644 --- a/source/gameengine/GameLogic/SCA_XORController.h +++ b/source/gameengine/GameLogic/SCA_XORController.h @@ -36,7 +36,7 @@ class SCA_XORController : public SCA_IController { - Py_Header; + Py_Header //virtual void Trigger(class SCA_LogicManager* logicmgr); public: SCA_XORController(SCA_IObject* gameobj); diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h index 41802a0a19f..32872592cc5 100644 --- a/source/gameengine/Ketsji/BL_Shader.h +++ b/source/gameengine/Ketsji/BL_Shader.h @@ -116,7 +116,7 @@ public: */ class BL_Shader : public PyObjectPlus { - Py_Header; + Py_Header private: typedef std::vector<BL_Uniform*> BL_UniformVec; typedef std::vector<BL_DefUniform*> BL_UniformVecDef; diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h index a7db2ed1660..f3447356055 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h @@ -39,7 +39,7 @@ class KX_NetworkMessageActuator : public SCA_IActuator { - Py_Header; + Py_Header bool m_lastEvent; class NG_NetworkScene* m_networkscene; // needed for replication STR_String m_toPropName; diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h index 7ec8f26f8ce..75800d9b9fa 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h @@ -40,7 +40,7 @@ class NG_NetworkScene; class KX_NetworkMessageSensor : public SCA_ISensor { // note: Py_Header MUST BE the first listed here - Py_Header; + Py_Header NG_NetworkScene *m_NetworkScene; // The subject we filter on. diff --git a/source/gameengine/Ketsji/KX_ArmatureSensor.h b/source/gameengine/Ketsji/KX_ArmatureSensor.h index 1b0168266a3..683a54f65de 100644 --- a/source/gameengine/Ketsji/KX_ArmatureSensor.h +++ b/source/gameengine/Ketsji/KX_ArmatureSensor.h @@ -40,7 +40,7 @@ struct bConstraint; class KX_ArmatureSensor : public SCA_ISensor { - Py_Header; + Py_Header //class CExpression* m_rightexpr; protected: diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 236bd6afdc8..2736516bf33 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -32,7 +32,7 @@ class KX_Scene; class KX_BlenderMaterial : public PyObjectPlus, public RAS_IPolyMaterial { - Py_Header; + Py_Header public: // -------------------------------- KX_BlenderMaterial(); diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 77438b8f48a..14a307794db 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -200,7 +200,26 @@ float KX_Camera::GetScale() const return m_camdata.m_scale; } +/* +* Gets the horizontal size of the sensor - for camera matching. +*/ +float KX_Camera::GetSensorWidth() const +{ + return m_camdata.m_sensor_x; +} +/* +* Gets the vertical size of the sensor - for camera matching. +*/ +float KX_Camera::GetSensorHeight() const +{ + return m_camdata.m_sensor_y; +} +/** Gets the mode FOV is calculating from sensor dimensions */ +short KX_Camera::GetSensorFit() const +{ + return m_camdata.m_sensor_fit; +} float KX_Camera::GetCameraNear() const { diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h index 4c8cf21a7bf..e9c4e99aa3b 100644 --- a/source/gameengine/Ketsji/KX_Camera.h +++ b/source/gameengine/Ketsji/KX_Camera.h @@ -50,7 +50,7 @@ bool ConvertPythonToCamera(PyObject * value, KX_Camera **object, bool py_none_ok class KX_Camera : public KX_GameObject { - Py_Header; + Py_Header protected: friend class KX_Scene; /** Camera parameters (clips distances, focal length). These @@ -199,6 +199,12 @@ public: float GetLens() const; /** Gets the ortho scale. */ float GetScale() const; + /** Gets the horizontal size of the sensor - for camera matching */ + float GetSensorWidth() const; + /** Gets the vertical size of the sensor - for camera matching */ + float GetSensorHeight() const; + /** Gets the mode FOV is calculating from sensor dimensions */ + short GetSensorFit() const; /** Gets the near clip distance. */ float GetCameraNear() const; /** Gets the far clip distance. */ diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index c06904ea56b..a6344ae380a 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -49,7 +49,7 @@ class KX_CameraActuator : public SCA_IActuator { - Py_Header; + Py_Header private : /** Object that will be tracked. */ SCA_IObject *m_ob; diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index ebaeed9aafe..b513b141f3e 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -42,7 +42,7 @@ class KX_GameObject; class KX_ConstraintActuator : public SCA_IActuator { - Py_Header; + Py_Header protected: // Damp time (int), int m_posDampTime; diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.h b/source/gameengine/Ketsji/KX_ConstraintWrapper.h index 8f559881a2e..980221bd4b3 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.h +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.h @@ -37,7 +37,7 @@ class KX_ConstraintWrapper : public PyObjectPlus { - Py_Header; + Py_Header public: KX_ConstraintWrapper(PHY_ConstraintType ctype,int constraintId,class PHY_IPhysicsEnvironment* physenv); virtual ~KX_ConstraintWrapper (); diff --git a/source/gameengine/Ketsji/KX_FontObject.h b/source/gameengine/Ketsji/KX_FontObject.h index 15d455b7313..8fc7a9e9f28 100644 --- a/source/gameengine/Ketsji/KX_FontObject.h +++ b/source/gameengine/Ketsji/KX_FontObject.h @@ -38,7 +38,7 @@ class KX_FontObject : public KX_GameObject { public: - Py_Header; + Py_Header KX_FontObject( void* sgReplicationInfo, SG_Callbacks callbacks, RAS_IRenderTools* rendertools, diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h index 1c05d152d39..ebc6712a2dd 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.h +++ b/source/gameengine/Ketsji/KX_GameActuator.h @@ -40,7 +40,7 @@ class KX_GameActuator : public SCA_IActuator { - Py_Header; + Py_Header protected: int m_mode; bool m_restart; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index d3ed9991c31..c240a7fcf84 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1880,7 +1880,7 @@ PyTypeObject KX_GameObject::Type = { PyObject* KX_GameObject::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast<KX_GameObject*>(self_v); - return PyUnicode_FromString(self->GetName().ReadPtr()); + return PyUnicode_From_STR_String(self->GetName()); } PyObject* KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -2683,7 +2683,7 @@ PyObject* KX_GameObject::PyGetPhysicsId() PyObject* KX_GameObject::PyGetPropertyNames() { - PyObject *list= ConvertKeysToPython(); + PyObject *list= ConvertKeysToPython(); if(m_attr_dict) { PyObject *key, *value; diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 69bc394cbfc..245a92a96de 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -80,7 +80,7 @@ void KX_GameObject_Mathutils_Callback_Init(void); */ class KX_GameObject : public SCA_IObject { - Py_Header; + Py_Header protected: bool m_bDyna; diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h index 5ee008ac5e3..fa26bbaa6e1 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.h +++ b/source/gameengine/Ketsji/KX_IpoActuator.h @@ -37,7 +37,7 @@ class KX_IpoActuator : public SCA_IActuator { - Py_Header; + Py_Header private: /** Computes the IPO start time from the current time and the current frame. */ diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 5de6adc5af4..a9be588e6b2 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1251,6 +1251,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) cam->GetScale(), nearfrust, farfrust, + cam->GetSensorFit(), frustum ); if (!cam->GetViewport()) { @@ -1268,6 +1269,9 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) area, viewport, cam->GetLens(), + cam->GetSensorWidth(), + cam->GetSensorHeight(), + cam->GetSensorFit(), nearfrust, farfrust, frustum diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 40f157ef0a4..5a02da07e43 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -387,8 +387,7 @@ public: void SetUseOverrideFrameColor(bool overrideFrameColor); /** - * Enables/disables the use of the framing bar color of the Blender file's scenes. - * @param useSceneFrameColor The new setting. + * Check if the frame color is being overridden. */ bool GetUseOverrideFrameColor(void) const; diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h index cd472311bcf..bb081e6a444 100644 --- a/source/gameengine/Ketsji/KX_Light.h +++ b/source/gameengine/Ketsji/KX_Light.h @@ -44,7 +44,7 @@ class MT_Transform; class KX_LightObject : public KX_GameObject { - Py_Header; + Py_Header protected: RAS_LightObject m_lightobj; class RAS_IRenderTools* m_rendertools; //needed for registering and replication of lightobj diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index 754ad511669..fec1d9d296c 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -129,7 +129,7 @@ PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* args, PyObject* kwds) return NULL; } - return PyUnicode_FromString(matname.Ptr()); + return PyUnicode_From_STR_String(matname); } @@ -147,7 +147,7 @@ PyObject* KX_MeshProxy::PyGetTextureName(PyObject* args, PyObject* kwds) return NULL; } - return PyUnicode_FromString(matname.Ptr()); + return PyUnicode_From_STR_String(matname); } diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h index d5292b5108d..f59418a5de2 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.h +++ b/source/gameengine/Ketsji/KX_MeshProxy.h @@ -41,7 +41,7 @@ bool ConvertPythonToMesh(PyObject * value, class RAS_MeshObject **object, bool p class KX_MeshProxy : public CValue { - Py_Header; + Py_Header class RAS_MeshObject* m_meshobj; public: diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h index 5fb576eec28..277af87f9f2 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h @@ -47,7 +47,7 @@ class KX_RayCast; class KX_MouseFocusSensor : public SCA_MouseSensor { - Py_Header; + Py_Header public: diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.h b/source/gameengine/Ketsji/KX_NavMeshObject.h index 287b2b24fa9..ad128a0891d 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.h +++ b/source/gameengine/Ketsji/KX_NavMeshObject.h @@ -36,7 +36,7 @@ class MT_Transform; class KX_NavMeshObject: public KX_GameObject { - Py_Header; + Py_Header protected: dtStatNavMesh* m_navMesh; diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h index 1caea59867a..26adcb993b8 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.h +++ b/source/gameengine/Ketsji/KX_NearSensor.h @@ -41,7 +41,7 @@ struct PHY_CollData; class KX_NearSensor : public KX_TouchSensor { - Py_Header; + Py_Header protected: float m_Margin; float m_ResetMargin; diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index fc6fcb66e28..aa0f844eb88 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -80,7 +80,7 @@ struct KX_LocalFlags { class KX_ObjectActuator : public SCA_IActuator { - Py_Header; + Py_Header MT_Vector3 m_force; MT_Vector3 m_torque; diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h index 8531675723a..484b137c2f5 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.h +++ b/source/gameengine/Ketsji/KX_ParentActuator.h @@ -41,7 +41,7 @@ class KX_ParentActuator : public SCA_IActuator { - Py_Header; + Py_Header /** Mode */ int m_mode; diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h index 0e4c2e71f3e..4f03c8fbfb1 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h @@ -37,7 +37,7 @@ class KX_PhysicsObjectWrapper : public PyObjectPlus { - Py_Header; + Py_Header public: KX_PhysicsObjectWrapper(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsEnvironment* physenv); virtual ~KX_PhysicsObjectWrapper(); diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index 82a93e76cf3..caef8ba5e2e 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -216,13 +216,13 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isCollider, KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialName, "getMaterialName() : returns the polygon material name, \"NoMaterial\" if no material\n") { - return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName()); + return PyUnicode_From_STR_String(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName()); } KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getTextureName, "getTexturelName() : returns the polygon texture name, \"NULL\" if no texture\n") { - return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName()); + return PyUnicode_From_STR_String(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName()); } KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex, diff --git a/source/gameengine/Ketsji/KX_PolyProxy.h b/source/gameengine/Ketsji/KX_PolyProxy.h index d8046b3fec6..44945e58c2a 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.h +++ b/source/gameengine/Ketsji/KX_PolyProxy.h @@ -38,7 +38,7 @@ class KX_PolyProxy : public CValue { - Py_Header; + Py_Header protected: class RAS_Polygon* m_polygon; class RAS_MeshObject* m_mesh; diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 3147d6ba4c9..29127ec11a0 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -346,13 +346,13 @@ KX_PYMETHODDEF_DOC(KX_PolygonMaterial, activate, "activate(rasty, cachingInfo)") PyObject* KX_PolygonMaterial::pyattr_get_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); - return PyUnicode_FromString(self->m_texturename.ReadPtr()); + return PyUnicode_From_STR_String(self->m_texturename); } PyObject* KX_PolygonMaterial::pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); - return PyUnicode_FromString(self->m_materialname.ReadPtr()); + return PyUnicode_From_STR_String(self->m_materialname); } /* this does not seem useful */ diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h index 78876c60409..f20a90f7deb 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.h +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h @@ -55,7 +55,7 @@ struct Image; */ class KX_PolygonMaterial : public PyObjectPlus, public RAS_IPolyMaterial { - Py_Header; + Py_Header private: /** Blender texture face structure. */ MTFace* m_tface; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index c3a141e7405..02e6ebea71b 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -815,7 +815,7 @@ static struct PyMethodDef game_methods[] = { {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (const char *)"Gets the estimated average frame rate"}, {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, (const char *)"Gets a list of blend files in the same directory as the current blend file"}, {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (const char *)"Prints GL Extension Info"}, - {"PrintMemInfo", (PyCFunction)pyPrintStats, METH_NOARGS, (const char *)"Print engine stastics"}, + {"PrintMemInfo", (PyCFunction)pyPrintStats, METH_NOARGS, (const char *)"Print engine statistics"}, /* library functions */ {"LibLoad", (PyCFunction)gLibLoad, METH_VARARGS|METH_KEYWORDS, (const char *)""}, diff --git a/source/gameengine/Ketsji/KX_RadarSensor.h b/source/gameengine/Ketsji/KX_RadarSensor.h index 422313fcfef..ee803d9bdb9 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.h +++ b/source/gameengine/Ketsji/KX_RadarSensor.h @@ -41,7 +41,7 @@ class KX_RadarSensor : public KX_NearSensor { protected: - Py_Header; + Py_Header float m_coneradius; diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h index d797666d6ab..4c0009a5a4c 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.h +++ b/source/gameengine/Ketsji/KX_RaySensor.h @@ -43,7 +43,7 @@ class KX_RayCast; class KX_RaySensor : public SCA_ISensor { - Py_Header; + Py_Header STR_String m_propertyname; bool m_bFindMaterial; bool m_bXRay; diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index 4bb84663e9e..ec5cf305c3e 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -45,7 +45,7 @@ class SCA_IScene; class KX_SCA_AddObjectActuator : public SCA_IActuator { - Py_Header; + Py_Header /// Time field: lifetime of the new object int m_timeProp; diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h index eaad67ad0ea..5fefbb8cca5 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h @@ -42,7 +42,7 @@ class KX_SCA_DynamicActuator : public SCA_IActuator { - Py_Header; + Py_Header // dynamics operation to apply to the game object short m_dyn_operation; diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h index a6bbf258398..7a325257e59 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h @@ -41,7 +41,7 @@ class SCA_IScene; class KX_SCA_EndObjectActuator : public SCA_IActuator { - Py_Header; + Py_Header SCA_IScene* m_scene; public: diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h index 1e0e2155e62..3e07ec2665c 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h @@ -44,7 +44,7 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator { - Py_Header; + Py_Header // mesh reference (mesh to replace) RAS_MeshObject* m_mesh; diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index f1e0fdc8a50..9b8f7f27d80 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -2117,7 +2117,7 @@ PySequenceMethods KX_Scene::Sequence = { PyObject* KX_Scene::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Scene* self= static_cast<KX_Scene*>(self_v); - return PyUnicode_FromString(self->GetName().ReadPtr()); + return PyUnicode_From_STR_String(self->GetName()); } PyObject* KX_Scene::pyattr_get_objects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 67508f5741b..c8070736b7f 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -101,7 +101,7 @@ class KX_ObstacleSimulation; * */ class KX_Scene : public PyObjectPlus, public SCA_IScene { - Py_Header; + Py_Header #ifdef WITH_PYTHON PyObject* m_attr_dict; diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h index 30f325a775e..9064146a1d4 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.h +++ b/source/gameengine/Ketsji/KX_SceneActuator.h @@ -38,7 +38,7 @@ class KX_SceneActuator : public SCA_IActuator { - Py_Header; + Py_Header int m_mode; // (restart) has become a toggle internally... not in the interface though diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h index 174bcc8f990..b9119677f4f 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.h +++ b/source/gameengine/Ketsji/KX_SoundActuator.h @@ -57,7 +57,7 @@ typedef struct KX_3DSoundSettings class KX_SoundActuator : public SCA_IActuator { - Py_Header; + Py_Header bool m_isplaying; AUD_Reference<AUD_IFactory> m_sound; float m_volume; diff --git a/source/gameengine/Ketsji/KX_StateActuator.h b/source/gameengine/Ketsji/KX_StateActuator.h index 3d1dc64d891..aa17b687463 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.h +++ b/source/gameengine/Ketsji/KX_StateActuator.h @@ -44,7 +44,7 @@ */ class KX_StateActuator : public SCA_IActuator { - Py_Header; + Py_Header /** Make visible? */ enum { diff --git a/source/gameengine/Ketsji/KX_SteeringActuator.h b/source/gameengine/Ketsji/KX_SteeringActuator.h index 38be7bce57b..a0ae8e0d1d9 100644 --- a/source/gameengine/Ketsji/KX_SteeringActuator.h +++ b/source/gameengine/Ketsji/KX_SteeringActuator.h @@ -47,7 +47,7 @@ const int MAX_PATH_LENGTH = 128; class KX_SteeringActuator : public SCA_IActuator { - Py_Header; + Py_Header /** Target object */ KX_GameObject *m_target; diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index a111bf31cf6..1fae766aa13 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -51,7 +51,7 @@ class KX_TouchEventManager; class KX_TouchSensor : public SCA_ISensor { protected: - Py_Header; + Py_Header /** * The sensor should only look for objects with this property. diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index 9d267bfe89a..30e276c0021 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -40,7 +40,7 @@ class KX_TrackToActuator : public SCA_IActuator { - Py_Header; + Py_Header // Object reference. Actually, we use the object's 'life' SCA_IObject* m_object; // 3d toggle diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.h b/source/gameengine/Ketsji/KX_VehicleWrapper.h index f750912c95b..f6e360d34a8 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.h +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.h @@ -16,7 +16,7 @@ class PHY_IMotionState; ///Python interface to physics vehicles (primarily 4-wheel cars and 2wheel bikes) class KX_VehicleWrapper : public PyObjectPlus { - Py_Header; + Py_Header std::vector<PHY_IMotionState*> m_motionStates; diff --git a/source/gameengine/Ketsji/KX_VertexProxy.h b/source/gameengine/Ketsji/KX_VertexProxy.h index 4ae662faa12..905a4e0f4ab 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.h +++ b/source/gameengine/Ketsji/KX_VertexProxy.h @@ -38,7 +38,7 @@ class KX_VertexProxy : public CValue { - Py_Header; + Py_Header protected: class RAS_TexVert* m_vertex; diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.h b/source/gameengine/Ketsji/KX_VisibilityActuator.h index 0ffe1de6480..f5c45ecbd99 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.h +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.h @@ -37,7 +37,7 @@ class KX_VisibilityActuator : public SCA_IActuator { - Py_Header; + Py_Header /** Make visible? */ bool m_visible; diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h index 2056068a2ad..2120a18f139 100644 --- a/source/gameengine/Rasterizer/RAS_CameraData.h +++ b/source/gameengine/Rasterizer/RAS_CameraData.h @@ -36,6 +36,9 @@ struct RAS_CameraData { float m_lens; float m_scale; + float m_sensor_x; + float m_sensor_y; + short m_sensor_fit; float m_clipstart; float m_clipend; bool m_perspective; @@ -46,11 +49,15 @@ struct RAS_CameraData int m_viewporttop; float m_focallength; - RAS_CameraData(float lens = 35.0, float scale = 6.0, float clipstart = 0.1, float clipend = 5000.0, bool perspective = true, + RAS_CameraData(float lens = 35.0, float scale = 6.0, float sensor_x = 32.0, float sensor_y = 18.0, short sensor_fit = 0, + float clipstart = 0.1, float clipend = 5000.0, bool perspective = true, float focallength = 3.0, bool viewport = false, int viewportleft = 0, int viewportbottom = 0, int viewportright = 0, int viewporttop = 0) : m_lens(lens), m_scale(scale), + m_sensor_x(sensor_x), + m_sensor_y(sensor_y), + m_sensor_fit(sensor_fit), m_clipstart(clipstart), m_clipend(clipend), m_perspective(perspective), diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.cpp b/source/gameengine/Rasterizer/RAS_FramingManager.cpp index da6c230ffc1..8a5c10b3a3b 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.cpp +++ b/source/gameengine/Rasterizer/RAS_FramingManager.cpp @@ -39,25 +39,35 @@ ComputeDefaultFrustum( const float camnear, const float camfar, const float lens, + const float sensor_x, const float sensor_y, + const short sensor_fit, const float design_aspect_ratio, RAS_FrameFrustum & frustum -){ - - /* - * Magic Blender calculation. - * Blender does not give a Field of View as lens but a size - * at 16 units away from the lens. - */ - float halfSize = 16.f * camnear / lens; +){ + float halfSize; float sizeX; float sizeY; - if (design_aspect_ratio > 1.f) { - // halfsize defines the width + if(sensor_fit==RAS_SENSORFIT_AUTO) { + halfSize = (sensor_x / 2.f) * camnear / lens; + + if (design_aspect_ratio > 1.f) { + // halfsize defines the width + sizeX = halfSize; + sizeY = halfSize/design_aspect_ratio; + } else { + // halfsize defines the height + sizeX = halfSize * design_aspect_ratio; + sizeY = halfSize; + } + } + else if(sensor_fit==RAS_SENSORFIT_HOR) { + halfSize = (sensor_x / 2.f) * camnear / lens; sizeX = halfSize; sizeY = halfSize/design_aspect_ratio; - } else { - // halfsize defines the height + } + else { + halfSize = (sensor_y / 2.f) * camnear / lens; sizeX = halfSize * design_aspect_ratio; sizeY = halfSize; } @@ -77,6 +87,7 @@ ComputeDefaultOrtho( const float camfar, const float scale, const float design_aspect_ratio, + const short sensor_fit, RAS_FrameFrustum & frustum ) { @@ -84,12 +95,22 @@ ComputeDefaultOrtho( float sizeX; float sizeY; - if (design_aspect_ratio > 1.f) { - // halfsize defines the width + if(sensor_fit==RAS_SENSORFIT_AUTO) { + if (design_aspect_ratio > 1.f) { + // halfsize defines the width + sizeX = halfSize; + sizeY = halfSize/design_aspect_ratio; + } else { + // halfsize defines the height + sizeX = halfSize * design_aspect_ratio; + sizeY = halfSize; + } + } + else if(sensor_fit==RAS_SENSORFIT_HOR) { sizeX = halfSize; sizeY = halfSize/design_aspect_ratio; - } else { - // halfsize defines the height + } + else { sizeX = halfSize * design_aspect_ratio; sizeY = halfSize; } @@ -199,6 +220,7 @@ ComputeFrustum( const RAS_Rect &availableViewport, const RAS_Rect &viewport, const float lens, + const float sensor_x, const float sensor_y, const short sensor_fit, const float camnear, const float camfar, RAS_FrameFrustum &frustum @@ -224,6 +246,9 @@ ComputeFrustum( camnear, camfar, lens, + sensor_x, + sensor_y, + sensor_fit, design_aspect_ratio, frustum ); @@ -269,6 +294,7 @@ RAS_FramingManager:: const float scale, const float camnear, const float camfar, + const short sensor_fit, RAS_FrameFrustum &frustum ) { @@ -293,6 +319,7 @@ RAS_FramingManager:: camfar, scale, design_aspect_ratio, + sensor_fit, frustum ); diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.h b/source/gameengine/Rasterizer/RAS_FramingManager.h index 38ea8f4e07a..612142234e3 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.h +++ b/source/gameengine/Rasterizer/RAS_FramingManager.h @@ -184,6 +184,14 @@ enum RAS_CullingMode RAS_CULLING_NONE }; +/* Should match CAMERA_SENSOR_FIT... from DNA_camera_types.h */ +enum RAS_SensorFit +{ + RAS_SENSORFIT_AUTO = 0, + RAS_SENSORFIT_HOR, + RAS_SENSORFIT_VERT +}; + /** * @section RAS_FramingManager * This class helps to compute a view frustum @@ -229,6 +237,7 @@ public : const float scale, const float camnear, const float camfar, + const short sensor_fit, RAS_FrameFrustum &frustum ); @@ -239,6 +248,7 @@ public : const RAS_Rect &availableViewport, const RAS_Rect &viewport, const float lens, + const float sensor_x, const float sensor_y, const short sensor_fit, const float camnear, const float camfar, RAS_FrameFrustum &frustum @@ -250,6 +260,8 @@ public : const float camnear, const float camfar, const float lens, + const float sensor_x, const float sensor_y, + const short sensor_fit, const float design_aspect_ratio, RAS_FrameFrustum & frustum ); @@ -261,6 +273,7 @@ public : const float camfar, const float scale, const float design_aspect_ratio, + const short sensor_fit, RAS_FrameFrustum & frustum ); diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 912d5864560..a349b45e403 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -214,6 +214,8 @@ void ImageRender::Render() } else { float lens = m_camera->GetLens(); + float sensor_x = m_camera->GetSensorWidth(); + float sensor_y = m_camera->GetSensorHeight(); bool orthographic = !m_camera->GetCameraData()->m_perspective; float nearfrust = m_camera->GetCameraNear(); float farfrust = m_camera->GetCameraFar(); @@ -233,6 +235,7 @@ void ImageRender::Render() farfrust, m_camera->GetScale(), aspect_ratio, + m_camera->GetSensorFit(), frustrum ); @@ -244,6 +247,9 @@ void ImageRender::Render() nearfrust, farfrust, lens, + sensor_x, + sensor_y, + RAS_SENSORFIT_AUTO, aspect_ratio, frustrum); |