* Merge trunk up to r39790.

* Subversion bump (also for init_userdef_do_versions).
* Minor fix for compilation without ffmpeg.
This commit is contained in:
Joerg Mueller 2011-08-30 08:22:03 +00:00
commit 43ab8e8624
180 changed files with 6289 additions and 1990 deletions

@ -274,6 +274,11 @@ endif()
TEST_SSE_SUPPORT()
# don't store paths to libs for portable distrobution
if(WITH_INSTALL_PORTABLE)
set(CMAKE_SKIP_BUILD_RPATH TRUE)
endif()
#-----------------------------------------------------------------------------
# Initialize un-cached vars, avoid unused warning
@ -445,21 +450,20 @@ if(UNIX AND NOT APPLE)
endif()
if(WITH_OPENCOLLADA)
set(OPENCOLLADA /usr/local/opencollada CACHE PATH "OpenCollada Directory")
mark_as_advanced(OPENCOLLADA)
set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer xml2)
set(OPENCOLLADA_INCLUDE_DIR ${OPENCOLLADA})
find_package(OpenCOLLADA)
if(OPENCOLLADA_FOUND)
set(PCRE /usr CACHE PATH "PCRE Directory")
mark_as_advanced(PCRE)
set(PCRE_LIBPATH ${PCRE}/lib)
set(PCRE_LIB pcre)
set(PCRE /usr CACHE PATH "PCRE Directory")
mark_as_advanced(PCRE)
set(PCRE_LIBPATH ${PCRE}/lib)
set(PCRE_LIB pcre)
set(EXPAT /usr CACHE PATH "Expat Directory")
mark_as_advanced(EXPAT)
set(EXPAT_LIBPATH ${EXPAT}/lib)
set(EXPAT_LIB expat)
set(EXPAT /usr CACHE PATH "Expat Directory")
mark_as_advanced(EXPAT)
set(EXPAT_LIBPATH ${EXPAT}/lib)
set(EXPAT_LIB expat)
else()
set(WITH_OPENCOLLADA OFF)
endif()
endif()
if(WITH_MEM_JEMALLOC)
@ -684,9 +688,15 @@ elseif(WIN32)
endif()
if(WITH_OPENCOLLADA)
set(OPENCOLLADA_INCLUDE_DIR
${LIBDIR}/opencollada/include
set(OPENCOLLADA_INCLUDE_DIRS
${LIBDIR}/opencollada/include/COLLADAStreamWriter/include
${LIBDIR}/opencollada/include/COLLADABaseUtils/include
${LIBDIR}/opencollada/include/COLLADAFramework/include
${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader/include
${LIBDIR}/opencollada/include/GeneratedSaxParser/include
)
set(OPENCOLLADA_LIBRARIES
${LIBDIR}/opencollada/lib/OpenCOLLADASaxFrameworkLoader.lib
${LIBDIR}/opencollada/lib/OpenCOLLADAFramework.lib
@ -832,7 +842,13 @@ elseif(WIN32)
if(WITH_OPENCOLLADA)
set(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
set(OPENCOLLADA_INCLUDE_DIR ${OPENCOLLADA}/include)
set(OPENCOLLADA_INCLUDE_DIRS
${LIBDIR}/gcc/opencollada/include/COLLADAStreamWriter/include
${LIBDIR}/gcc/opencollada/include/COLLADABaseUtils/include
${LIBDIR}/gcc/opencollada/include/COLLADAFramework/include
${LIBDIR}/gcc/opencollada/include/COLLADASaxFrameworkLoader/include
${LIBDIR}/gcc/opencollada/include/GeneratedSaxParser/include
)
set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
set(PCRE_LIB pcre)
@ -1043,7 +1059,15 @@ elseif(APPLE)
if(WITH_OPENCOLLADA)
set(OPENCOLLADA ${LIBDIR}/opencollada)
set(OPENCOLLADA_INCLUDE_DIR ${OPENCOLLADA}/include)
set(OPENCOLLADA_INCLUDE_DIRS
${LIBDIR}/opencollada/include/COLLADAStreamWriter
${LIBDIR}/opencollada/include/COLLADABaseUtils
${LIBDIR}/opencollada/include/COLLADAFramework
${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader
${LIBDIR}/opencollada/include/GeneratedSaxParser
)
set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
set(OPENCOLLADA_LIBRARIES "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
#pcre is bundled with openCollada

@ -272,12 +272,12 @@ if env['OURPLATFORM']=='darwin':
# for now, Mac builders must download and install the 3DxWare 10 Beta 4 driver framework from 3Dconnexion
# necessary header file lives here when installed:
# /Library/Frameworks/3DconnexionClient.framework/Versions/Current/Headers/ConnexionClientAPI.h
if env['WITH_BF_3DMOUSE'] == 1 and not os.path.exists('/Library/Frameworks/3DconnexionClient.framework'):
print "3D_CONNEXION_CLIENT_LIBRARY not found, disabling WITH_BF_3DMOUSE" # avoid build errors !
env['WITH_BF_3DMOUSE'] = 0
else:
env.Append(LINKFLAGS=['-weak_framework','3DconnexionClient'])
if env['WITH_BF_3DMOUSE'] == 1:
if not os.path.exists('/Library/Frameworks/3DconnexionClient.framework'):
print "3D_CONNEXION_CLIENT_LIBRARY not found, disabling WITH_BF_3DMOUSE" # avoid build errors !
env['WITH_BF_3DMOUSE'] = 0
else:
env.Append(LINKFLAGS=['-weak_framework','3DconnexionClient'])
if env['WITH_BF_OPENMP'] == 1:
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):

@ -0,0 +1,118 @@
# - Find OpenCOLLADA library
# Find the native OpenCOLLADA includes and library
# This module defines
# OPENCOLLADA_INCLUDE_DIRS, where to find COLLADABaseUtils/ and
# COLLADAFramework/, Set when OPENCOLLADA_INCLUDE_DIR is found.
# OPENCOLLADA_LIBRARIES, libraries to link against to use OpenCOLLADA.
# OPENCOLLADA_ROOT_DIR, The base directory to search for OpenCOLLADA.
# This can also be an environment variable.
# OPENCOLLADA_FOUND, If false, do not try to use OpenCOLLADA.
#
# also defined, but not for general use are
# OPENCOLLADA_LIBRARY, where to find the OpenCOLLADA library.
#=============================================================================
# Copyright 2011 Blender Foundation.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# note about include paths, there are 2 ways includes are set
#
# Where '/usr/include/opencollada' is the root dir:
# /usr/include/opencollada/COLLADABaseUtils/COLLADABUPlatform.h
#
# Where '/opt/opencollada' is the base dir:
# /opt/opencollada/COLLADABaseUtils/include/COLLADABUPlatform.h
# If OPENCOLLADA_ROOT_DIR was defined in the environment, use it.
IF(NOT OPENCOLLADA_ROOT_DIR AND NOT $ENV{OPENCOLLADA_ROOT_DIR} STREQUAL "")
SET(OPENCOLLADA_ROOT_DIR $ENV{OPENCOLLADA_ROOT_DIR})
ENDIF()
SET(_opencollada_FIND_INCLUDES
COLLADAStreamWriter
COLLADABaseUtils
COLLADAFramework
COLLADASaxFrameworkLoader
GeneratedSaxParser
)
SET(_opencollada_FIND_COMPONENTS
OpenCOLLADAStreamWriter
OpenCOLLADASaxFrameworkLoader
OpenCOLLADAFramework
OpenCOLLADABaseUtils
GeneratedSaxParser
UTF
MathMLSolver
pcre
ftoa
buffer
xml2
)
SET(_opencollada_SEARCH_DIRS
${OPENCOLLADA_ROOT_DIR}
/usr/local
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
)
SET(_opencollada_INCLUDES)
FOREACH(COMPONENT ${_opencollada_FIND_INCLUDES})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
# need to use this even thouh we are looking for a dir
FIND_FILE(OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR
NAMES
${COMPONENT}/include
${COMPONENT}
# Ubuntu ppa needs this.
# Alternative would be to suffix all members of search path
# but this is less trouble, just looks strange.
include/opencollada/${COMPONENT}
HINTS
${_opencollada_SEARCH_DIRS}
)
MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR)
LIST(APPEND _opencollada_INCLUDES "${OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR}")
ENDFOREACH()
SET(_opencollada_LIBRARIES)
FOREACH(COMPONENT ${_opencollada_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
FIND_LIBRARY(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY
NAMES
${COMPONENT}
HINTS
${_opencollada_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
# Ubuntu ppa needs this.
lib64/opencollada lib/opencollada
)
MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
LIST(APPEND _opencollada_LIBRARIES "${OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY}")
ENDFOREACH()
# handle the QUIETLY and REQUIRED arguments and set OPENCOLLADA_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenCOLLADA DEFAULT_MSG
_opencollada_LIBRARIES _opencollada_INCLUDES)
IF(OPENCOLLADA_FOUND)
SET(OPENCOLLADA_LIBRARIES ${_opencollada_LIBRARIES})
SET(OPENCOLLADA_INCLUDE_DIRS ${_opencollada_INCLUDES})
ENDIF(OPENCOLLADA_FOUND)

@ -1,4 +1,4 @@
# turn everything OFF CACHE FORCE BOOL) except for python which defaults to ON
# turn everything OFF except for python which defaults to ON
# and is needed for the UI
#
# Example usage:

@ -43,7 +43,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
set(CPACK_PACKAGE_RELOCATABLE "false")
set(CPACK_RPM_PACKAGE_LICENSE "GPLv2")
set(CPACK_RPM_PACKAGE_GROUP "Amusements/Graphics")
set(CPACK_RPM_PACKAGE_GROUP "Amusements/Multimedia")
set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_SOURCE_DIR}/build_files/package_spec/rpm/blender.spec.in")
endif()
endif()
@ -75,14 +75,14 @@ endmacro()
if(APPLE)
add_package_archive(
"blender-${BLENDER_VERSION}-r${BUILD_REV}-OSX-${CMAKE_OSX_ARCHITECTURES}"
"${PROJECT_NAME}-${BLENDER_VERSION}-r${BUILD_REV}-OSX-${CMAKE_OSX_ARCHITECTURES}"
"zip")
elseif(UNIX)
# platform name could be tweaked, to include glibc, and ensure processor is correct (i386 vs i686)
string(TOLOWER ${CMAKE_SYSTEM_NAME} PACKAGE_SYSTEM_NAME)
add_package_archive(
"blender-${BLENDER_VERSION}-r${BUILD_REV}-${PACKAGE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}"
"${PROJECT_NAME}-${BLENDER_VERSION}-r${BUILD_REV}-${PACKAGE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}"
"tar.bz2")
endif()

@ -9,6 +9,7 @@ Release: @CPACK_RPM_PACKAGE_RELEASE@%{?dist}
License: @CPACK_RPM_PACKAGE_LICENSE@
Group: @CPACK_RPM_PACKAGE_GROUP@
Vendor: @CPACK_RPM_PACKAGE_VENDOR@
Epoch: 1
%define _rpmdir @CPACK_RPM_DIRECTORY@
%define _rpmfilename @CPACK_RPM_FILE_NAME@

@ -316,7 +316,11 @@ if WITH_BF_QUICKTIME:
PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime']
#note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4
LLIBS = ['stdc++', 'SystemStubs']
#for 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore)
if MACOSX_DEPLOYMENT_TARGET == '10.7':
LLIBS = ['stdc++']
else:
LLIBS = ['stdc++', 'SystemStubs']
# some flags shuffling for different OS versions
if MAC_MIN_VERS == '10.3':

@ -23,11 +23,6 @@ with bpy.data.libraries.load(filepath) as (data_from, data_to):
setattr(data_to, attr, getattr(data_from, attr))
# the 'data_to' variables lists are
with bpy.data.libraries.load(filepath) as (data_from, data_to):
data_to.scenes = ["Scene"]
# the loaded objects can be accessed from 'data_to' outside of the context
# since loading the data replaces the strings for the datablocks or None
# if the datablock could not be loaded.

@ -0,0 +1,19 @@
"""
User Clear
++++++++++
This function is for advanced use only, misuse can crash blender since the user
count is used to prevent data being removed when it is used.
"""
# This example shows what _not_ to do, and will crash blender.
import bpy
# object which is in the scene.
obj = bpy.data.objects["Cube"]
# without this, removal would raise an error.
obj.user_clear()
# runs without an exception
# but will crash on redraw.
bpy.data.objects.remove(obj)

@ -0,0 +1,405 @@
********
Gotcha's
********
This document attempts to help you work with the Blender API in areas that can be troublesome and avoid practices that are known to give instability.
Using Operators
===============
Blender's operators are tools for users to access, that python can access them too is very useful nevertheless operators have limitations that can make them cumbersome to script.
Main limits are...
* Can't pass data such as objects, meshes or materials to operate on (operators use the context instead)
* The return value from calling an operator gives the success (if it finished or was canceled),
in some cases it would be more logical from an API perspective to return the result of the operation.
* Operators poll function can fail where an API function would raise an exception giving details on exactly why.
Why does an operator's poll fail?
---------------------------------
When calling an operator gives an error like this:
>>> bpy.ops.action.clean(threshold=0.001)
RuntimeError: Operator bpy.ops.action.clean.poll() failed, context is incorrect
Which raises the question as to what the correct context might be?
Typically operators check for the active area type, a selection or active object they can operate on, but some operators are more picky about when they run.
In most cases you can figure out what context an operator needs simply be seeing how its used in Blender and thinking about what it does.
Unfortunately if you're still stuck - the only way to **really** know whats going on is to read the source code for the poll function and see what its checking.
For python operators its not so hard to find the source since its included with with Blender and the source file/line is included in the operator reference docs.
Downloading and searching the C code isn't so simple, especially if you're not familiar with the C language but by searching the operator name or description you should be able to find the poll function with no knowledge of C.
.. note::
Blender does have the functionality for poll functions to describe why they fail, but its currently not used much, if you're interested to help improve our API feel free to add calls to ``CTX_wm_operator_poll_msg_set`` where its not obvious why poll fails.
>>> bpy.ops.gpencil.draw()
RuntimeError: Operator bpy.ops.gpencil.draw.poll() Failed to find Grease Pencil data to draw into
The operator still doesn't work!
--------------------------------
Certain operators in Blender are only intended for use in a specific context, some operators for example are only called from the properties window where they check the current material, modifier or constraint.
Examples of this are:
* :mod:`bpy.ops.texture.slot_move`
* :mod:`bpy.ops.constraint.limitdistance_reset`
* :mod:`bpy.ops.object.modifier_copy`
* :mod:`bpy.ops.buttons.file_browse`
Another possibility is that you are the first person to attempt to use this operator in a script and some modifications need to be made to the operator to run in a different context, if the operator should logically be able to run but fails when accessed from a script it should be reported to the bug tracker.
Stale Data
==========
No updates after setting values
-------------------------------
Sometimes you want to modify values from python and immediately access the updated values, eg:
Once changing the objects :class:`bpy.types.Object.location` you may want to access its transformation right after from :class:`bpy.types.Object.matrix_world`, but this doesn't work as you might expect.
Consider the calculations that might go into working out the objects final transformation, this includes:
* animation function curves.
* drivers and their pythons expressions.
* constraints
* parent objects and all of their f-curves, constraints etc.
To avoid expensive recalculations every time a property is modified, Blender defers making the actual calculations until they are needed.
However, while the script runs you may want to access the updated values.
This can be done by calling :class:`bpy.types.Scene.update` after modifying values which recalculates all data that is tagged to be updated.
Can I redraw during the script?
-------------------------------
The official answer to this is no, or... *"You don't want to do that"*.
To give some background on the topic...
While a script executes Blender waits for it to finish and is effectively locked until its done, while in this state Blender won't redraw or respond to user input.
Normally this is not such a problem because scripts distributed with Blender tend not to run for an extended period of time, nevertheless scripts *can* take ages to execute and its nice to see whats going on in the view port.
Tools that lock Blender in a loop and redraw are highly discouraged since they conflict with Blenders ability to run multiple operators at once and update different parts of the interface as the tool runs.
So the solution here is to write a **modal** operator, that is - an operator which defines a modal() function, See the modal operator template in the text editor.
Modal operators execute on user input or setup their own timers to run frequently, they can handle the events or pass through to be handled by the keymap or other modal operators.
Transform, Painting, Fly-Mode and File-Select are example of a modal operators.
Writing modal operators takes more effort then a simple ``for`` loop that happens to redraw but is more flexible and integrates better with Blenders design.
**Ok, Ok! I still want to draw from python**
If you insist - yes its possible, but scripts that use this hack wont be considered for inclusion in Blender and any issues with using it wont be considered bugs, this is also not guaranteed to work in future releases.
.. code-block:: python
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
Matrix multiplication is wrong
==============================
Every so often users complain that Blenders matrix math is wrong, the confusion comes from mathutils matrices being column-major to match OpenGL and the rest of Blenders matrix operations and stored matrix data.
This is different to **numpy** which is row-major which matches what you would expect when using conventional matrix math notation.
I can't edit the mesh in edit-mode!
===================================
Blenders EditMesh is an internal data structure (not saved and not exposed to python), this gives the main annoyance that you need to exit edit-mode to edit the mesh from python.
The reason we have not made much attempt to fix this yet is because we
will likely move to BMesh mesh API eventually, so any work on the API now will be wasted effort.
With the BMesh API we may expose mesh data to python so we can
write useful tools in python which are also fast to execute while in edit-mode.
For the time being this limitation just has to be worked around but we're aware its frustrating needs to be addressed.
EditBones, PoseBones, Bone... Bones
===================================
Armature Bones in Blender have three distinct data structures that contain them. If you are accessing the bones through one of them, you may not have access to the properties you really need.
.. note::
In the following examples ``bpy.context.object`` is assumed to be an armature object.
Edit Bones
----------
``bpy.context.object.data.edit_bones`` contains a editbones; to access them you must set the armature mode to edit mode first (editbones do not exist in object or pose mode). Use these to create new bones, set their head/tail or roll, change their parenting relationships to other bones, etc.
Example using :class:`bpy.types.EditBone` in armature editmode:
This is only possible in edit mode.
>>> bpy.context.object.data.edit_bones["Bone"].head = Vector((1.0, 2.0, 3.0))
This will be empty outside of editmode.
>>> mybones = bpy.context.selected_editable_bones
Returns an editbone only in edit mode.
>>> bpy.context.active_bone
Bones (Object Mode)
-------------------
``bpy.context.object.data.bones`` contains bones. These *live* in object mode, and have various properties you can change, note that the head and tail properties are read-only.
Example using :class:`bpy.types.Bone` in object or pose mode:
Returns a bone (not an editbone) outside of edit mode
>>> bpy.context.active_bone
This works, as with blender the setting can be edited in any mode
>>> bpy.context.object.data.bones["Bone"].use_deform = True
Accessible but read-only
>>> tail = myobj.data.bones["Bone"].tail
Pose Bones
----------
``bpy.context.object.pose.bones`` contains pose bones. This is where animation data resides, i.e. animatable transformations are applied to pose bones, as are constraints and ik-settings.
Examples using :class:`bpy.types.PoseBone` in object or pose mode:
.. code-block:: python
# Gets the name of the first constraint (if it exists)
bpy.context.object.pose.bones["Bone"].constraints[0].name
# Gets the last selected pose bone (pose mode only)
bpy.context.active_pose_bone
.. note::
Notice the pose is accessed from the object rather than the object data, this is why blender can have 2 or more objects sharing the same armature in different poses.
.. note::
Strictly speaking PoseBone's are not bones, they are just the state of the armature, stored in the :class:`bpy.types.Object` rather than the :class:`bpy.types.Armature`, the real bones are however accessible from the pose bones - :class:`bpy.types.PoseBone.bone`
Armature Mode Switching
-----------------------
While writing scripts that deal with armatures you may find you have to switch between modes, when doing so take care when switching out of editmode not to keep references to the edit-bones or their head/tail vectors. Further access to these will crash blender so its important the script clearly separates sections of the code which operate in different modes.
This is mainly an issue with editmode since pose data can be manipulated without having to be in pose mode, however for operator access you may still need to enter pose mode.
Unicode Problems
================
Python supports many different encpdings so there is nothing stopping you from writing a script in latin1 or iso-8859-15.
See `pep-0263 <http://www.python.org/dev/peps/pep-0263/>`_
However this complicates things for the python api because blend files themselves dont have an encoding.
To simplify the problem for python integration and script authors we have decieded all strings in blend files **must** be UTF-8 or ASCII compatible.
This means assigning strings with different encodings to an object names for instance will raise an error.
Paths are an exception to this rule since we cannot ignore the existane of non-utf-8 paths on peoples filesystems.
This means seemingly harmless expressions can raise errors, eg.
>>> print(bpy.data.filepath)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 10-21: ordinal not in range(128)
>>> bpy.context.object.name = bpy.data.filepath
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
TypeError: bpy_struct: item.attr= val: Object.name expected a string type, not str
Here are 2 ways around filesystem encoding issues:
>>> print(repr(bpy.data.filepath))
>>> import os
>>> filepath_bytes = os.fsencode(bpy.data.filepath)
>>> filepath_utf8 = filepath_bytes.decode('utf-8', "replace")
>>> bpy.context.object.name = filepath_utf8
Unicode encoding/decoding is a big topic with comprehensive python documentation, to avoid getting stuck too deep in encoding problems - here are some suggestions:
* Always use utf-8 encoiding or convert to utf-8 where the input is unknown.
* Avoid manipulating filepaths as strings directly, use ``os.path`` functions instead.
* Use ``os.fsencode()`` / ``os.fsdecode()`` rather then the built in string decoding functions when operating on paths.
* To print paths or to include them in the user interface use ``repr(path)`` first or ``"%r" % path`` with string formatting.
* **Possibly** - use bytes instead of python strings, when reading some input its less trouble to read it as binary data though you will still need to deciede how to treat any strings you want to use with Blender, some importers do this.
Strange errors using 'threading' module
=======================================
Python threading with Blender only works properly when the threads finish up before the script does. By using ``threading.join()`` for example.
Heres an example of threading supported by Blender:
.. code-block:: python
import threading
import time
def prod():
print(threading.current_thread().name, "Starting")
# do something vaguely useful
import bpy
from mathutils import Vector
from random import random
prod_vec = Vector((random() - 0.5, random() - 0.5, random() - 0.5))
print("Prodding", prod_vec)
bpy.data.objects["Cube"].location += prod_vec
time.sleep(random() + 1.0)
# finish
print(threading.current_thread().name, "Exiting")
threads = [threading.Thread(name="Prod %d" % i, target=prod) for i in range(10)]
print("Starting threads...")
for t in threads:
t.start()
print("Waiting for threads to finish...")
for t in threads:
t.join()
This an example of a timer which runs many times a second and moves the default cube continuously while Blender runs (Unsupported).
.. code-block:: python
def func():
print("Running...")
import bpy
bpy.data.objects['Cube'].location.x += 0.05
def my_timer():
from threading import Timer
t = Timer(0.1, my_timer)
t.start()
func()
my_timer()
Use cases like the one above which leave the thread running once the script finishes may seem to work for a while but end up causing random crashes or errors in Blenders own drawing code.
So far no work has gone into making Blenders python integration thread safe, so until its properly supported, best not make use of this.
.. note::
Pythons threads only allow co-currency and wont speed up you're scripts on multi-processor systems, the ``subprocess`` and ``multiprocess`` modules can be used with blender and make use of multiple CPU's too.
Help! My script crashes Blender
===============================
Ideally it would be impossible to crash Blender from python however there are some problems with the API where it can be made to crash.
Strictly speaking this is a bug in the API but fixing it would mean adding memory verification on every access since most crashes are caused by the python objects referencing Blenders memory directly, whenever the memory is freed, further python access to it can crash the script. But fixing this would make the scripts run very slow, or writing a very different kind of API which doesn't reference the memory directly.
Here are some general hints to avoid running into these problems.
* Be aware of memory limits, especially when working with large lists since Blender can crash simply by running out of memory.
* Many hard to fix crashes end up being because of referencing freed data, when removing data be sure not to hold any references to it.
* Modules or classes that remain active while Blender is used, should not hold references to data the user may remove, instead, fetch data from the context each time the script is activated.
* Crashes may not happen every time, they may happen more on some configurations/operating-systems.
Undo/Redo
---------
Undo invalidates all :class:`bpy.types.ID` instances (Object, Scene, Mesh etc).
This example shows how you can tell undo changes the memory locations.
>>> hash(bpy.context.object)
-9223372036849950810
>>> hash(bpy.context.object)
-9223372036849950810
# ... move the active object, then undo
>>> hash(bpy.context.object)
-9223372036849951740
As suggested above, simply not holding references to data when Blender is used interactively by the user is the only way to ensure the script doesn't become unstable.
Array Re-Allocation
-------------------
When adding new points to a curve or vertices's/edges/faces to a mesh, internally the array which stores this data is re-allocated.
.. code-block:: python
bpy.ops.curve.primitive_bezier_curve_add()
point = bpy.context.object.data.splines[0].bezier_points[0]
bpy.context.object.data.splines[0].bezier_points.add()
# this will crash!
point.co = 1.0, 2.0, 3.0
This can be avoided by re-assigning the point variables after adding the new one or by storing indices's to the points rather then the points themselves.
The best way is to sidestep the problem altogether add all the points to the curve at once. This means you don't have to worry about array re-allocation and its faster too since reallocating the entire array for every point added is inefficient.
Removing Data
-------------
**Any** data that you remove shouldn't be modified or accessed afterwards, this includes f-curves, drivers, render layers, timeline markers, modifiers, constraints along with objects, scenes, groups, bones.. etc.
This is a problem in the API at the moment that we should eventually solve.

@ -0,0 +1,373 @@
*******************
Python API Overview
*******************
This document is to give an understanding of how python and blender fit together, covering some of the functionality that isn't obvious from reading the API reference and example scripts.
Python in Blender
=================
Blender embeds a python interpreter which is started with blender and stays active. This interpreter runs scripts to draw the user interface and is used for some of Blender's internal tools too.
This is a typical python environment so tutorials on how to write python scripts will work running the scripts in blender too. Blender provides the :mod:`bpy` module to the python interpreter. This module can be imported in a script and gives access to blender data, classes, and functions. Scripts that deal with blender data will need to import this module.
Here is a simple example of moving a vertex of the object named **Cube**:
.. code-block:: python
import bpy
bpy.data.objects["Cube"].data.vertices[0].co.x += 1.0
This modifies Blender's internal data directly. When you run this in the interactive console you will see the 3D viewport update.
The Default Environment
=======================
When developing your own scripts it may help to understand how blender sets up its python environment. Many python scripts come bundled with blender and can be used as a reference because they use the same API that script authors write tools in. Typical usage for scripts include: user interface, import/export, scene manipulation, automation, defining your own toolset and customization.
On startup blender scans the ``scripts/startup/`` directory for python modules and imports them. The exact location of this directory depends on your installation. `See the directory layout docs <http://wiki.blender.org/index.php/Doc:2.5/Manual/Introduction/Installing_Blender/DirectoryLayout>`_
Script Loading
==============
This may seem obvious but it's important to note the difference between executing a script directly or importing it as a module.
Scripts that extend blender - define classes that exist beyond the scripts execution, this makes future access to these classes (to unregister for example) more difficult than importing as a module where class instance is kept in the module and can be accessed by importing that module later on.
For this reason it's preferable to only use directly execute scripts that don't extend blender by registering classes.
Here are some ways to run scripts directly in blender.
* Loaded in the text editor and press **Run Script**.
* Typed or pasted into the interactive console.
* Execute a python file from the command line with blender, eg:
``blender --python /home/me/my_script.py``
To run as modules:
* The obvious way, ``import some_module`` command from the text window or interactive console.
* Open as a text block and tick "Register" option, this will load with the blend file.
* copy into one of the directories ``scripts/startup``, where they will be automatically imported on startup.
* define as an addon, enabling the addon will load it as a python module.
Addons
------
Some of blenders functionality is best kept optional, alongside scripts loaded at startup we have addons which are kept in their own directory ``scripts/addons``, and only load on startup if selected from the user preferences.
The only difference between addons and built-in python modules is that addons must contain a **bl_info** variable which blender uses to read metadata such as name, author, category and URL.
The user preferences addon listing uses **bl_info** to display information about each addon.
`See Addons <http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons>`_ for details on the **bl_info** dictionary.
Integration through Classes
===========================
Running python scripts in the text editor is useful for testing but youll want to extend blender to make tools accessible like other built-in functionality.
The blender python api allows integration for:
* :class:`bpy.types.Panel`
* :class:`bpy.types.Menu`
* :class:`bpy.types.Operator`
* :class:`bpy.types.PropertyGroup`
* :class:`bpy.types.KeyingSet`
* :class:`bpy.types.RenderEngine`
This is intentionally limited. Currently, for more advanced features such as mesh modifiers, object types, or shader nodes, C/C++ must be used.
For python intergration Blender defines methods which are common to all types. This works by creating a python subclass of a Blender class which contains variables and functions specified by the parent class which are pre-defined to interface with Blender.
For example:
.. code-block:: python
import bpy
class SimpleOperator(bpy.types.Operator):
bl_idname = "object.simple_operator"
bl_label = "Tool Name"
def execute(self, context):
print("Hello World")
return {'FINISHED'}
bpy.utils.register_class(SimpleOperator)
First note that we subclass a member of :mod:`bpy.types`, this is common for all classes which can be integrated with blender and used so we know if this is an Operator and not a Panel when registering.
Both class properties start with a **bl_** prefix. This is a convention used to distinguish blender properties from those you add yourself.
Next see the execute function, which takes an instance of the operator and the current context. A common prefix is not used for functions.
Lastly the register function is called, this takes the class and loads it into blender. See `Class Registration`_.
Regarding inheritance, blender doesn't impose restrictions on the kinds of class inheritance used, the registration checks will use attributes and functions defined in parent classes.
class mix-in example:
.. code-block:: python
import bpy
class BaseOperator:
def execute(self, context):
print("Hello World BaseClass")
return {'FINISHED'}
class SimpleOperator(bpy.types.Operator, BaseOperator):
bl_idname = "object.simple_operator"
bl_label = "Tool Name"
bpy.utils.register_class(SimpleOperator)
Notice these classes don't define an ``__init__(self)`` function. While ``__init__()`` and ``__del__()`` will be called if defined, the class instances lifetime only spans the execution. So a panel for example will have a new instance for every redraw, for this reason there is rarely a cause to store variables in the panel instance. Instead, persistent variables should be stored in Blenders data so that the state can be restored when blender is restarted.
.. note:: Modal operators are an exception, keeping their instance variable as blender runs, see modal operator template.
So once the class is registered with blender, instancing the class and calling the functions is left up to blender. In fact you cannot instance these classes from the script as you would expect with most python API's.
To run operators you can call them through the operator api, eg:
.. code-block:: python
import bpy
bpy.ops.object.simple_operator()
User interface classes are given a context in which to draw, buttons window, file header, toolbar etc, then they are drawn when that area is displayed so they are never called by python scripts directly.
Registration
============
Module Registration
-------------------
Blender modules loaded at startup require ``register()`` and ``unregister()`` functions. These are the *only* functions that blender calls from your code, which is otherwise a regular python module.
A simple blender/python module can look like this:
.. code-block:: python
import bpy
class SimpleOperator(bpy.types.Operator):
""" See example above """
def register():
bpy.utils.register_class(SimpleOperator)
def unregister():
bpy.utils.unregister_class(SimpleOperator)
if __name__ == "__main__":
register()
These functions usually appear at the bottom of the script containing class registration sometimes adding menu items. You can also use them for internal purposes setting up data for your own tools but take care since register won't re-run when a new blend file is loaded.
The register/unregister calls are used so it's possible to toggle addons and reload scripts while blender runs.
If the register calls were placed in the body of the script, registration would be called on import, meaning there would be no distinction between importing a module or loading its classes into blender.
This becomes problematic when a script imports classes from another module making it difficult to manage which classes are being loaded and when.
The last 2 lines are only for testing:
.. code-block:: python
if __name__ == "__main__":
register()
This allows the script to be run directly in the text editor to test changes.
This ``register()`` call won't run when the script is imported as a module since ``__main__`` is reserved for direct execution.
Class Registration
------------------
Registering a class with blender results in the class definition being loaded into blender, where it becomes available alongside existing functionality.
Once this class is loaded you can access it from :mod:`bpy.types`, using the bl_idname rather than the classes original name.
When loading a class, blender performs sanity checks making sure all required properties and functions are found, that properties have the correct type, and that functions have the right number of arguments.
Mostly you will not need concern yourself with this but if there is a problem with the class definition it will be raised on registering:
Using the function arguments ``def execute(self, context, spam)``, will raise an exception:
``ValueError: expected Operator, SimpleOperator class "execute" function to have 2 args, found 3``
Using ``bl_idname = 1`` will raise.
``TypeError: validating class error: Operator.bl_idname expected a string type, not int``
Multiple-Classes
^^^^^^^^^^^^^^^^
Loading classes into blender is described above, for simple cases calling :mod:`bpy.utils.register_class` (SomeClass) is sufficient, but when there are many classes or a packages submodule has its own classes it can be tedious to list them all for registration.
For more convenient loading/unloading :mod:`bpy.utils.register_module` (module) and :mod:`bpy.utils.unregister_module` (module) functions exist.
A script which defines many of its own operators, panels menus etc. you only need to write:
.. code-block:: python
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.unregister_module(__name__)
Internally blender collects subclasses on registrable types, storing them by the module in which they are defined. By passing the module name to :mod:`bpy.utils.register_module` blender can register all classes created by this module and its submodules.
Inter Classes Dependencies
^^^^^^^^^^^^^^^^^^^^^^^^^^
When customizing blender you may want to group your own settings together, after all, they will likely have to co-exist with other scripts. To group these properties classes need to be defined, for groups within groups or collections within groups you can find yourself having to deal with order of registration/unregistration.
Custom properties groups are themselves classes which need to be registered.
Say you want to store material settings for a custom engine.
.. code-block:: python
# Create new property
# bpy.data.materials[0].my_custom_props.my_float
import bpy
class MyMaterialProps(bpy.types.PropertyGroup):
my_float = bpy.props.FloatProperty()
def register():
bpy.utils.register_class(MyMaterialProps)
bpy.types.Material.my_custom_props = bpy.props.PointerProperty(type=MyMaterialProps)
def unregister():
del bpy.types.Material.my_custom_props
bpy.utils.unregister_class(MyMaterialProps)
if __name__ == "__main__":
register()
.. note::
*The class must be registered before being used in a property, failing to do so will raise an error:*
``ValueError: bpy_struct "Material" registration error: my_custom_props could not register``
.. code-block:: python
# Create new property group with a sub property
# bpy.data.materials[0].my_custom_props.sub_group.my_float
import bpy
class MyMaterialSubProps(bpy.types.PropertyGroup):
my_float = bpy.props.FloatProperty()
class MyMaterialGroupProps(bpy.types.PropertyGroup):
sub_group = bpy.props.PointerProperty(type=MyMaterialSubProps)
def register():
bpy.utils.register_class(MyMaterialSubProps)
bpy.utils.register_class(MyMaterialGroupProps)
bpy.types.Material.my_custom_props = bpy.props.PointerProperty(type=MyMaterialGroupProps)
def unregister():
del bpy.types.Material.my_custom_props
bpy.utils.unregister_class(MyMaterialGroupProps)
bpy.utils.unregister_class(MyMaterialSubProps)
if __name__ == "__main__":
register()
.. note::
*The lower most class needs to be registered first and that unregister() is a mirror of register()*
Manipulating Classes
^^^^^^^^^^^^^^^^^^^^
Properties can be added and removed as blender runs, normally happens on register or unregister but for some special cases it may be useful to modify types as the script runs.
For example:
.. code-block:: python
# add a new property to an existing type
bpy.types.Object.my_float = bpy.props.FloatProperty()
# remove
del bpy.types.Object.my_float
This works just as well for PropertyGroup subclasses you define yourself.
.. code-block:: python
class MyPropGroup(bpy.types.PropertyGroup):
pass
MyPropGroup.my_float = bpy.props.FloatProperty()
...this is equivalent to:
.. code-block:: python
class MyPropGroup(bpy.types.PropertyGroup):
my_float = bpy.props.FloatProperty()
Dynamic Defined-Classes (Advanced)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In some cases the specifier for data may not be in blender, renderman shader definitions for example and it may be useful to define types and remove them on the fly.
.. code-block:: python
for i in range(10):
idname = "object.operator_%d" % i
def func(self, context):
print("Hello World", self.bl_idname)
return {'FINISHED'}
opclass = type("DynOp%d" % i,
(bpy.types.Operator, ),
{"bl_idname": idname, "bl_label": "Test", "execute": func},
)
bpy.utils.register_class(opclass)
.. note::
Notice ``type()`` is called to define the class. This is an alternative syntax for class creation in python, better suited to constructing classes dynamically.
Calling these operators:
>>> bpy.ops.object.operator_1()
Hello World OBJECT_OT_operator_1
{'FINISHED'}
>>> bpy.ops.object.operator_2()
Hello World OBJECT_OT_operator_2
{'FINISHED'}

@ -0,0 +1,468 @@
***********************
Quickstart Introduction
***********************
Intro
=====
This API is generally stable but some areas are still being added and improved.
The Blender/Python API can do the following:
* Edit any data the user interface can (Scenes, Meshes, Particles etc.)
* Modify user preferences, keymaps and themes
* Run tools with own settings
* Create user interface elements such as menus, headers and panels
* Create new tools
* Create interactive tools
* Create new rendering engines that integrate with Blender
* Define new settings in existing Blender data
* Draw in the 3D view using OpenGL commands from Python
The Blender/Python API **can't** (yet)...
* Create new space types.
* Assign custom properties to every type.
* Define callbacks or listeners to be notified when data is changed.
Before Starting
===============
This document isn't intended to fully cover each topic. Rather, its purpose is to familiarize you with Blender 2.5's new Python API.
A quick list of helpful things to know before starting:
* Blender uses Python 3.x; some 3rd party extensions are not available yet.
* The interactive console in Blender 2.5 has been improved; testing one-liners in the console is a good way to learn.
* Button tool tips show Python attributes and operator names.
* Right clicking on buttons and menu items directly links to API documentation.
* For more examples, the text menu has a templates section where some example operators can be found.
* To examine further scripts distributed with Blender, see ``~/.blender/scripts/startup/bl_ui`` for the user interface and ``~/.blender/scripts/startup/bl_op`` for operators.
Key Concepts
============
Data Access
-----------
Accessing datablocks
^^^^^^^^^^^^^^^^^^^^
Python accesses Blender's data in the same way as the animation system and user interface, which means any setting that is changed via a button can also be changed from Python.
Accessing data from the currently loaded blend file is done with the module :mod:`bpy.data`. This gives access to library data. For example:
>>> bpy.data.objects
<bpy_collection[3], BlendDataObjects>
>>> bpy.data.scenes
<bpy_collection[1], BlendDataScenes>
>>> bpy.data.materials
<bpy_collection[1], BlendDataMaterials>
About Collections
^^^^^^^^^^^^^^^^^
You'll notice that an index as well as a string can be used to access members of the collection.
Unlike Python's dictionaries, both methods are acceptable; however, the index of a member may change while running Blender.
>>> list(bpy.data.objects)
[bpy.data.objects["Cube"], bpy.data.objects["Plane"]]
>>> bpy.data.objects['Cube']
bpy.data.objects["Cube"]
>>> bpy.data.objects[0]
bpy.data.objects["Cube"]
Accessing attributes
^^^^^^^^^^^^^^^^^^^^
Once you have a data block such as a material, object, groups etc. its attributes can be accessed just like changing a setting in the interface; in fact, the button tooltip also displays the Python attribute which can help in finding what settings to change in a script.
>>> bpy.data.objects[0].name
'Camera'
>>> bpy.data.scenes["Scene"]
bpy.data.scenes['Scene']
>>> bpy.data.materials.new("MyMaterial")
bpy.data.materials['MyMaterial']
For testing what data to access it's useful to use the "Console", which is its own space type in Blender 2.5. This supports auto-complete, giving you a fast way to dig into different data in your file.
Example of a data path that can be quickly found via the console:
>>> bpy.data.scenes[0].render.resolution_percentage
100
>>> bpy.data.scenes[0].objects["Torus"].data.vertices[0].co.x
1.0
Custom Properties
^^^^^^^^^^^^^^^^^
Python can access properties on any datablock that has an ID (data that can be linked in and accessed from :mod:`bpy.data`. When assigning a property, you can make up your own names, these will be created when needed or overwritten if they exist.
This data is saved with the blend file and copied with objects.
Example:
.. code-block:: python
bpy.context.object["MyOwnProperty"] = 42
if "SomeProp" in bpy.context.object:
print("Property found")
# Use the get function like a python dictionary
# which can have a fallback value.
value = bpy.data.scenes["Scene"].get("test_prop", "fallback value")
# dictionaries can be assigned as long as they only use basic types.
group = bpy.data.groups.new("MyTestGroup")
group["GameSettings"] = {"foo": 10, "bar": "spam", "baz": {}}
del group["GameSettings"]
Note that these properties can only be assigned basic Python types.
* int, float, string
* array of ints/floats
* dictionary (only string keys types on this list)
These properties are valid outside of Python. They can be animated by curves or used in driver paths.
Context
-------
While it's useful to be able to access data directly by name or as a list, it's more common to operate on the user's selection. The context is always available from '''bpy.context''' and can be used to get the active object, scene, tool settings along with many other attributes.
Common-use cases:
>>> bpy.context.object
>>> bpy.context.selected_objects
>>> bpy.context.visible_bones
Note that the context is read-only. These values cannot be modified directly, though they may be changed by running API functions or by using the data API.
So ``bpy.context.object = obj`` will raise an error.
But ``bpy.context.scene.objects.active = obj`` will work as expected.
The context attributes change depending on where it is accessed. The 3D view has different context members to the Console, so take care when accessing context attributes that the user state is known.
See :mod:`bpy.context` API reference
Operators (Tools)
-----------------
Operators are tools generally accessed by the user from buttons, menu items or key shortcuts. From the user perspective they are a tool but Python can run these with its own settings through the :mod:`bpy.ops` module.
Examples:
>>> bpy.ops.mesh.flip_normals()
{'FINISHED'}
>>> bpy.ops.mesh.hide(unselected=False)
{'FINISHED'}
>>> bpy.ops.object.scale_apply()
{'FINISHED'}
.. note::
The menu item: Help -> Operator Cheat Sheet" gives a list of all operators and their default values in Python syntax, along with the generated docs. This is a good way to get an overview of all blender's operators.
Operator Poll()
^^^^^^^^^^^^^^^
Many operators have a "poll" function which may check that the mouse is a valid area or that the object is in the correct mode (Edit Mode, Weight Paint etc). When an operator's poll function fails within python, an exception is raised.
For example, calling bpy.ops.view3d.render_border() from the console raises the following error:
.. code-block:: python
RuntimeError: Operator bpy.ops.view3d.render_border.poll() failed, context is incorrect
In this case the context must be the 3d view with an active camera.
To avoid using try/except clauses wherever operators are called you can call the operators own .poll() function to check if it can run in the current context.
.. code-block:: python
if bpy.ops.view3d.render_border.poll():
bpy.ops.view3d.render_border()
Integration
===========
Python scripts can integrate with Blender in the following ways:
* By defining a rendering engine.
* By defining operators.
* By defining menus, headers and panels.
* By inserting new buttons into existing menus, headers and panels
In Python, this is done by defining a class, which is a subclass of an existing type.
Example Operator
----------------
.. literalinclude:: ../../../release/scripts/templates/operator_simple.py
Once this script runs, ``SimpleOperator`` is registered with Blender and can be called from the operator search popup or added to the toolbar.
To run the script:
#. Highlight the above code then press Ctrl+C to copy it.
#. Start Blender
#. Press Ctrl+Right twice to change to the Scripting layout.
#. Press Ctrl+V to paste the code into the text panel (the upper left frame).
#. Click on the button **Run Script**.
#. Move you're mouse into the 3D view, press spacebar for the operator search
menu, and type "Simple".
#. Click on the "Simple Operator" item found in search.
.. seealso:: The class members with the **bl_** prefix are documented in the API
reference :class:`bpy.types.Operator`
Example Panel
-------------
Panels register themselves as a class, like an operator. Notice the extra **bl_** variables used to set the context they display in.
.. literalinclude:: ../../../release/scripts/templates/ui_panel_simple.py
To run the script:
#. Highlight the above code then press Ctrl+C to copy it
#. Start Blender
#. Press Ctrl+Right twice to change to the Scripting layout
#. Press Ctrl+V to paste the code into the text panel (the upper left frame)
#. Click on the button **Run Script**.
To view the results:
#. Select the the default cube.
#. Click on the Object properties icon in the buttons panel (far right; appears as a tiny cube).
#. Scroll down to see a panel named **Hello World Panel**.
#. Changing the object name also updates **Hello World Panel's** Name: field.
Note the row distribution and the label and properties that are available through the code.
.. seealso:: :class:`bpy.types.Panel`
Types
=====
Blender defines a number of Python types but also uses Python native types.
Blender's Python API can be split up into 3 categories.
Native Types
------------
In simple cases returning a number or a string as a custom type would be cumbersome, so these are accessed as normal python types.
* blender float/int/boolean -> float/int/boolean
* blender enumerator -> string
>>> C.object.rotation_mode = 'AXIS_ANGLE'
* blender enumerator (multiple) -> set of strings
.. code-block:: python
# setting multiple camera overlay guides
bpy.context.scene.camera.data.show_guide = {'GOLDEN', 'CENTER'}
# passing as an operator argument for report types
self.report({'WARNING', 'INFO'}, "Some message!")
Internal Types
--------------
Used for Blender datablocks and collections: :class:`bpy.types.bpy_struct`
For data that contains its own attributes groups/meshes/bones/scenes... etc.
There are 2 main types that wrap Blenders data, one for datablocks (known internally as bpy_struct), another for properties.
>>> bpy.context.object
bpy.data.objects['Cube']
>>> C.scene.objects
bpy.data.scenes['Scene'].objects
Note that these types reference Blender's data so modifying them is immediately visible.
Mathutils Types
---------------
Used for vectors, quaternion, eulers, matrix and color types, accessible from :mod:`mathutils`
Some attributes such as :class:`bpy.types.Object.location`, :class:`bpy.types.PoseBone.rotation_euler` and :class:`bpy.types.Scene.cursor_location` can be accessed as special math types which can be used together and manipulated in various useful ways.
Example of a matrix, vector multiplication:
.. code-block:: python
bpy.context.object.matrix_world * bpy.context.object.data.verts[0].co
.. note::
mathutils types keep a reference to Blender's internal data so changes can
be applied back.
Example:
.. code-block:: python
# modifies the Z axis in place.
bpy.context.object.location.z += 2.0
# location variable holds a reference to the object too.
location = bpy.context.object.location
location *= 2.0
# Copying the value drops the reference so the value can be passed to
# functions and modified without unwanted side effects.
location = bpy.context.object.location.copy()
Animation
=========
There are 2 ways to add keyframes through Python.
The first is through key properties directly, which is similar to inserting a keyframe from the button as a user. You can also manually create the curves and keyframe data, then set the path to the property. Here are examples of both methods.
Both examples insert a keyframe on the active object's Z axis.
Simple example:
.. code-block:: python
obj = bpy.context.object
obj.location[2] = 0.0
obj.keyframe_insert(data_path="location", frame=10.0, index=2)
obj.location[2] = 1.0
obj.keyframe_insert(data_path="location", frame=20.0, index=2)
Using Low-Level Functions:
.. code-block:: python
obj = bpy.context.object
obj.animation_data_create()
obj.animation_data.action = bpy.data.actions.new(name="MyAction")
fcu_z = obj.animation_data.action.fcurves.new(data_path="location", index=2)
fcu_z.keyframe_points.add(2)
fcu_z.keyframe_points[0].co = 10.0, 0.0
fcu_z.keyframe_points[1].co = 20.0, 1.0
Style Conventions
=================
For Blender 2.5 we have chosen to follow python suggested style guide to avoid mixing styles amongst our own scripts and make it easier to use python scripts from other projects.
Using our style guide for your own scripts makes it easier if you eventually want to contribute them to blender.
This style guide is known as pep8 and can be found `here <http://www.python.org/dev/peps/pep-0008>`_
A brief listing of pep8 criteria.
* camel caps for class names: MyClass
* all lower case underscore separated module names: my_module
* indentation of 4 spaces (no tabs)
* spaces around operators. ``1 + 1``, not ``1+1``
* only use explicit imports, (no importing '*')
* don't use single line: ``if val: body``, separate onto 2 lines instead.
As well as pep8 we have other conventions used for blender python scripts.
* Use single quotes for enums, and double quotes for strings.
Both are of course strings but in our internal API enums are unique items from a limited set. eg.
.. code-block:: python
bpy.context.scene.render.file_format = 'PNG'
bpy.context.scene.render.filepath = "//render_out"
* pep8 also defines that lines should not exceed 79 characters, we felt this is too restrictive so this is optional per script.
Periodically we run checks for pep8 compliance on blender scripts, for scripts to be included in this check add this line as a comment at the top of the script.
``# <pep8 compliant>``
To enable line length checks use this instead.
``# <pep8-80 compliant>``

@ -60,11 +60,13 @@ if __import__("sys").modules.get("bpy") is None:
# Switch for quick testing
if 1:
# full build
EXCLUDE_INFO_DOCS = False
EXCLUDE_MODULES = ()
FILTER_BPY_TYPES = None
FILTER_BPY_OPS = None
else:
EXCLUDE_INFO_DOCS = False
# for testing so doc-builds dont take so long.
EXCLUDE_MODULES = (
"bpy.context",
@ -77,7 +79,7 @@ else:
"bpy.types", # supports filtering
"bpy.ops", # supports filtering
"bpy_extras",
# "bge",
"bge",
"aud",
"bgl",
"blf",
@ -85,7 +87,7 @@ else:
"mathutils.geometry",
)
FILTER_BPY_TYPES = ("bpy_struct", "Panel", "Menu", "Operator", "RenderEngine") # allow
FILTER_BPY_TYPES = ("bpy_struct", "Panel", "ID") # allow
FILTER_BPY_OPS = ("import.scene", ) # allow
# for quick rebuilds
@ -96,6 +98,13 @@ sphinx-build doc/python_api/sphinx-in doc/python_api/sphinx-out
"""
# extra info, not api reference docs
# stored in ./rst/info/
INFO_DOCS = (
("info_quickstart.rst", "Blender/Python Quickstart: new to blender/scripting and want to get you're feet wet?"),
("info_overview.rst", "Blender/Python API Overview: a more complete explanation of python integration"),
("info_gotcha.rst", "Gotcha's: some of the problems you may come up against when writing scripts"),
)
# import rpdb2; rpdb2.start_embedded_debugger('test')
@ -744,6 +753,8 @@ def pyrna2sphinx(BASEPATH):
descr = prop.name
fw(" `%s`, %s, %s\n\n" % (prop.identifier, descr, type_descr))
write_example_ref(" ", fw, "bpy.types." + struct.identifier + "." + func.identifier)
fw("\n")
# python methods
@ -999,14 +1010,17 @@ def rna2sphinx(BASEPATH):
fw("\n")
fw("============================\n")
fw("Blender/Python Documentation\n")
fw("============================\n")
fw("\n")
fw("\n")
fw("* `Quickstart Intro <http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro>`_ if you are new to scripting in blender and want to get you're feet wet!\n")
fw("* `Blender/Python Overview <http://wiki.blender.org/index.php/Dev:2.5/Py/API/Overview>`_ for a more complete explanation of python integration in blender\n")
fw("\n")
if not EXCLUDE_INFO_DOCS:
fw("============================\n")
fw("Blender/Python Documentation\n")
fw("============================\n")
fw("\n")
fw("\n")
fw(".. toctree::\n")
fw(" :maxdepth: 1\n\n")
for info, info_desc in INFO_DOCS:
fw(" %s <%s>\n\n" % (info_desc, info))
fw("\n")
fw("===================\n")
fw("Application Modules\n")
@ -1208,6 +1222,11 @@ def rna2sphinx(BASEPATH):
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "change_log.rst"), BASEPATH)
if not EXCLUDE_INFO_DOCS:
for info, info_desc in INFO_DOCS:
shutil.copy2(os.path.join(BASEPATH, "..", "rst", info), BASEPATH)
if 0:
filepath = os.path.join(BASEPATH, "bpy.rst")
file = open(filepath, "w")

@ -3,11 +3,21 @@
# bash source/blender/python/doc/sphinx_doc_gen.sh
# ssh upload means you need an account on the server
# ----------------------------------------------------------------------------
# Upload vars
# disable for testing
DO_UPLOAD=true
BLENDER="./blender.bin"
SSH_USER="ideasman42"
SSH_HOST=$SSH_USER"@emo.blender.org"
SSH_UPLOAD="/data/www/vhosts/www.blender.org/documentation" # blender_python_api_VERSION, added after
# ----------------------------------------------------------------------------
# Blender Version & Info
# 'Blender 2.53 (sub 1) Build' --> '2_53_1' as a shell script.
# "_".join(str(v) for v in bpy.app.version)
# custom blender vars
@ -28,28 +38,52 @@ SSH_UPLOAD_FULL=$SSH_UPLOAD/"blender_python_api_"$BLENDER_VERSION
SPHINXBASE=doc/python_api/
# ----------------------------------------------------------------------------
# Generate reStructuredText (blender/python only)
# dont delete existing docs, now partial updates are used for quick builds.
$BLENDER --background --factory-startup --python $SPHINXBASE/sphinx_doc_gen.py
# html
sphinx-build $SPHINXBASE/sphinx-in $SPHINXBASE/sphinx-out
cp $SPHINXBASE/sphinx-out/contents.html $SPHINXBASE/sphinx-out/index.html
ssh $SSH_USER@emo.blender.org 'rm -rf '$SSH_UPLOAD_FULL'/*'
rsync --progress -avze "ssh -p 22" $SPHINXBASE/sphinx-out/* $SSH_HOST:$SSH_UPLOAD_FULL/
# ----------------------------------------------------------------------------
# Generate HTML (sphinx)
## symlink the dir to a static URL
#ssh $SSH_USER@emo.blender.org 'rm '$SSH_UPLOAD'/250PythonDoc && ln -s '$SSH_UPLOAD_FULL' '$SSH_UPLOAD'/250PythonDoc'
sphinx-build -n -b html $SPHINXBASE/sphinx-in $SPHINXBASE/sphinx-out
# better redirect
ssh $SSH_USER@emo.blender.org 'echo "<html><head><title>Redirecting...</title><meta http-equiv=\"REFRESH\" content=\"0;url=../blender_python_api_'$BLENDER_VERSION'/\"></head><body>Redirecting...</body></html>" > '$SSH_UPLOAD'/250PythonDoc/index.html'
# pdf
sphinx-build -b latex $SPHINXBASE/sphinx-in $SPHINXBASE/sphinx-out
cd $SPHINXBASE/sphinx-out
make
cd -
# ----------------------------------------------------------------------------
# Generate PDF (sphinx/laytex)
# rename so local PDF has matching name.
sphinx-build -n -b latex $SPHINXBASE/sphinx-in $SPHINXBASE/sphinx-out
make -C $SPHINXBASE/sphinx-out
mv $SPHINXBASE/sphinx-out/contents.pdf $SPHINXBASE/sphinx-out/blender_python_reference_$BLENDER_VERSION.pdf
rsync --progress -avze "ssh -p 22" $SPHINXBASE/sphinx-out/blender_python_reference_$BLENDER_VERSION.pdf $SSH_HOST:$SSH_UPLOAD_FULL/blender_python_reference_$BLENDER_VERSION.pdf
# ----------------------------------------------------------------------------
# Upload to blender servers, comment this section for testing
if $DO_UPLOAD ; then
cp $SPHINXBASE/sphinx-out/contents.html $SPHINXBASE/sphinx-out/index.html
ssh $SSH_USER@emo.blender.org 'rm -rf '$SSH_UPLOAD_FULL'/*'
rsync --progress -avze "ssh -p 22" $SPHINXBASE/sphinx-out/* $SSH_HOST:$SSH_UPLOAD_FULL/
## symlink the dir to a static URL
#ssh $SSH_USER@emo.blender.org 'rm '$SSH_UPLOAD'/250PythonDoc && ln -s '$SSH_UPLOAD_FULL' '$SSH_UPLOAD'/250PythonDoc'
# better redirect
ssh $SSH_USER@emo.blender.org 'echo "<html><head><title>Redirecting...</title><meta http-equiv=\"REFRESH\" content=\"0;url=../blender_python_api_'$BLENDER_VERSION'/\"></head><body>Redirecting...</body></html>" > '$SSH_UPLOAD'/250PythonDoc/index.html'
# rename so local PDF has matching name.
rsync --progress -avze "ssh -p 22" $SPHINXBASE/sphinx-out/blender_python_reference_$BLENDER_VERSION.pdf $SSH_HOST:$SSH_UPLOAD_FULL/blender_python_reference_$BLENDER_VERSION.pdf
fi
# ----------------------------------------------------------------------------
# Print some useful text
echo ""
echo "Finished! view the docs from: "
echo " html:" $SPHINXBASE/sphinx-out/contents.html
echo " pdf:" $SPHINXBASE/sphinx-out/blender_python_reference_$BLENDER_VERSION.pdf

@ -71,6 +71,7 @@
#define avio_open url_fopen
#define avio_tell url_ftell
#define avio_close url_fclose
#define avio_size url_fsize
#endif
/* there are some version inbetween, which have avio_... functions but no
@ -130,4 +131,19 @@ int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
}
#endif
static inline
int64_t av_get_pts_from_frame(AVFormatContext *avctx, AVFrame * picture)
{
int64_t pts = picture->pkt_pts;
if (pts == AV_NOPTS_VALUE) {
pts = picture->pkt_dts;
}
if (pts == AV_NOPTS_VALUE) {
pts = 0;
}
return pts;
}
#endif

@ -429,7 +429,7 @@ static int compare_len(const void *p1, const void *p2)
return -1;
}
void MEM_printmemlist_stats()
void MEM_printmemlist_stats(void)
{
MemHead *membl;
MemPrintBlock *pb, *printblock;

@ -133,7 +133,7 @@ std::istream& operator >> (std::istream& is,Vector& v)
{ IOTrace("Stream input Vector (vector or ZERO)");
char storage[10];
EatWord(is,"[]",storage,10);
if (strlen(storage)==0) {
if (storage[0]=='\0') {
Eat(is,'[');
is >> v(0);
Eat(is,',');
@ -194,7 +194,7 @@ std::istream& operator >> (std::istream& is,Rotation& r)
{ IOTrace("Stream input Rotation (Matrix or EULERZYX, EULERZYZ,RPY, ROT, IDENTITY)");
char storage[10];
EatWord(is,"[]",storage,10);
if (strlen(storage)==0) {
if (storage[0]=='\0') {
Eat(is,'[');
for (int i=0;i<3;i++) {
is >> r(i,0);
@ -255,7 +255,7 @@ std::istream& operator >> (std::istream& is,Frame& T)
{ IOTrace("Stream input Frame (Rotation,Vector) or DH[...]");
char storage[10];
EatWord(is,"[",storage,10);
if (strlen(storage)==0) {
if (storage[0]=='\0') {
Eat(is,'[');
is >> T.M;
is >> T.p;

@ -58,7 +58,7 @@ def load_image(imagepath,
For formats blender can read, simply return the path that is given.
:type convert_callback: function
:return: an image or None
:rtype: :class:`Image`
:rtype: :class:`bpy.types.Image`
"""
import os
import bpy

@ -252,10 +252,10 @@ def axis_conversion(from_forward='Y', from_up='Z', to_forward='Y', to_up='Z'):
def axis_conversion_ensure(operator, forward_attr, up_attr):
"""
Function to ensure an operator has valid axis conversion settings, intended
to be used from :class:`Operator.check`.
to be used from :class:`bpy.types.Operator.check`.
:arg operator: the operator to access axis attributes from.
:type operator: :class:`Operator`
:type operator: :class:`bpy.types.Operator`
:arg forward_attr: attribute storing the forward axis
:type forward_attr: string
:arg up_attr: attribute storing the up axis

@ -35,7 +35,7 @@ def mesh_linked_faces(mesh):
other mesh elements within 1 mesh datablock.
:arg mesh: the mesh used to group with.
:type mesh: :class:`Mesh`
:type mesh: :class:`bpy.types.Mesh`
:return: lists of lists containing faces.
:rtype: list
"""
@ -125,9 +125,9 @@ def edge_loops_from_faces(mesh, faces=None, seams=()):
[[(0, 1), (4, 8), (3, 8)], ...]
:arg mesh: the mesh used to get edge loops from.
:type mesh: :class:`Mesh`
:type mesh: :class:`bpy.types.Mesh`
:arg faces: optional face list to only use some of the meshes faces.
:type faces: :class:`MeshFaces`, sequence or or NoneType
:type faces: :class:`bpy.types.MeshFaces`, sequence or or NoneType
:return: return a list of edge vertex index lists.
:rtype: list
"""
@ -450,7 +450,7 @@ def face_random_points(num_points, faces):
:arg num_points: the number of random points to generate on each face.
:type int:
:arg faces: list of the faces to generate points on.
:type faces: :class:`MeshFaces`, sequence
:type faces: :class:`bpy.types.MeshFaces`, sequence
:return: list of random points over all faces.
:rtype: list
"""

@ -33,11 +33,11 @@ def add_object_align_init(context, operator):
Return a matrix using the operator settings and view context.
:arg context: The context to use.
:type context: :class:`Context`
:type context: :class:`bpy.types.Context`
:arg operator: The operator, checked for location and rotation properties.
:type operator: :class:`Operator`
:type operator: :class:`bpy.types.Operator`
:return: the matrix from the context and settings.
:rtype: :class:`Matrix`
:rtype: :class:`mathutils.Matrix`
"""
from mathutils import Matrix, Vector, Euler
@ -92,13 +92,13 @@ def object_data_add(context, obdata, operator=None):
location, rotation and layer.
:arg context: The context to use.
:type context: :class:`Context`
:type context: :class:`bpy.types.Context`
:arg obdata: the data used for the new object.
:type obdata: valid object data type or None.
:arg operator: The operator, checked for location and rotation properties.
:type operator: :class:`Operator`
:type operator: :class:`bpy.types.Operator`
:return: the newly created object in the scene.
:rtype: :class:`ObjectBase`
:rtype: :class:`bpy.types.ObjectBase`
"""
scene = context.scene

@ -31,14 +31,14 @@ def region_2d_to_vector_3d(region, rv3d, coord):
coordinate.
:arg region: region of the 3D viewport, typically bpy.context.region.
:type region: :class:`Region`
:type region: :class:`bpy.types.Region`
:arg rv3d: 3D region data, typically bpy.context.space_data.region_3d.
:type rv3d: :class:`RegionView3D`
:type rv3d: :class:`bpy.types.RegionView3D`
:arg coord: 2d coordinates relative to the region:
(event.mouse_region_x, event.mouse_region_y) for example.
:type coord: 2d vector
:return: normalized 3d vector.
:rtype: :class:`Vector`
:rtype: :class:`mathutils.Vector`
"""
from mathutils import Vector
@ -65,9 +65,9 @@ def region_2d_to_location_3d(region, rv3d, coord, depth_location):
*depth_location*.
:arg region: region of the 3D viewport, typically bpy.context.region.
:type region: :class:`Region`
:type region: :class:`bpy.types.Region`
:arg rv3d: 3D region data, typically bpy.context.space_data.region_3d.
:type rv3d: :class:`RegionView3D`
:type rv3d: :class:`bpy.types.RegionView3D`
:arg coord: 2d coordinates relative to the region;
(event.mouse_region_x, event.mouse_region_y) for example.
:type coord: 2d vector
@ -75,7 +75,7 @@ def region_2d_to_location_3d(region, rv3d, coord, depth_location):
there is no defined depth with a 2d region input.
:type depth_location: 3d vector
:return: normalized 3d vector.
:rtype: :class:`Vector`
:rtype: :class:`mathutils.Vector`
"""
from mathutils import Vector
from mathutils.geometry import intersect_point_line
@ -114,13 +114,13 @@ def location_3d_to_region_2d(region, rv3d, coord):
Return the *region* relative 2d location of a 3d position.
:arg region: region of the 3D viewport, typically bpy.context.region.
:type region: :class:`Region`
:type region: :class:`bpy.types.Region`
:arg rv3d: 3D region data, typically bpy.context.space_data.region_3d.
:type rv3d: :class:`RegionView3D`
:type rv3d: :class:`bpy.types.RegionView3D`
:arg coord: 3d worldspace location.
:type coord: 3d vector
:return: 2d location
:rtype: :class:`Vector`
:rtype: :class:`mathutils.Vector`
"""
from mathutils import Vector

@ -287,7 +287,7 @@ class EditBone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup):
Transform the the bones head, tail, roll and envalope (when the matrix has a scale component).
:arg matrix: 3x3 or 4x4 transformation matrix.
:type matrix: :class:`Matrix`
:type matrix: :class:`mathutils.Matrix`
:arg scale: Scale the bone envalope by the matrix.
:type scale: bool
:arg roll: Correct the roll to point in the same relative direction to the head and tail.

@ -179,7 +179,7 @@ def execute(context):
# special exception. its possible the command loaded a new user interface
if hash(sc) != hash(context.space_data):
return
return {'FINISHED'}
bpy.ops.console.scrollback_append(text=sc.prompt + line, type='INPUT')

@ -199,19 +199,32 @@ class BakeAction(Operator):
bl_label = "Bake Action"
bl_options = {'REGISTER', 'UNDO'}
frame_start = IntProperty(name="Start Frame",
frame_start = IntProperty(
name="Start Frame",
description="Start frame for baking",
default=1, min=1, max=300000)
frame_end = IntProperty(name="End Frame",
min=0, max=300000,
default=1,
)
frame_end = IntProperty(
name="End Frame",
description="End frame for baking",
default=250, min=1, max=300000)
step = IntProperty(name="Frame Step",
min=1, max=300000,
default=250,
)
step = IntProperty(
name="Frame Step",
description="Frame Step",
default=1, min=1, max=120)
only_selected = BoolProperty(name="Only Selected",
default=True)
clear_consraints = BoolProperty(name="Clear Constraints",
default=False)
min=1, max=120,
default=1,
)
only_selected = BoolProperty(
name="Only Selected",
default=True,
)
clear_consraints = BoolProperty(
name="Clear Constraints",
default=False,
)
bake_types = EnumProperty(
name="Bake Data",
options={'ENUM_FLAG'},

@ -73,7 +73,7 @@ class DATA_PT_context_mesh(MeshButtonsPanel, Panel):
ob = context.object
mesh = context.mesh
space = context.space_data
layout.prop(context.scene.tool_settings, "mesh_select_mode", index=0, text="Vertex")
if ob:
layout.template_ID(ob, "data")
elif mesh:

@ -60,6 +60,7 @@ class SEQUENCER_HT_header(Header):
layout.separator()
layout.operator("sequencer.refresh_all")
layout.template_running_jobs()
elif st.view_type == 'SEQUENCER_PREVIEW':
layout.separator()
layout.operator("sequencer.refresh_all")
@ -245,6 +246,7 @@ class SEQUENCER_MT_strip(Menu):
layout.operator("sequencer.images_separate")
layout.operator("sequencer.offset_clear")
layout.operator("sequencer.deinterlace_selected_movies")
layout.operator("sequencer.rebuild_proxy")
layout.separator()
layout.operator("sequencer.duplicate")
@ -582,6 +584,7 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel):
col = split.column()
col.prop(strip, "filepath", text="")
col.prop(strip, "mpeg_preseek", text="MPEG Preseek")
col.prop(strip, "streamindex", text="Stream Index")
# TODO, sound???
# end drawing filename
@ -752,7 +755,7 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel):
class SEQUENCER_PT_proxy(SequencerButtonsPanel, Panel):
bl_label = "Proxy"
bl_label = "Proxy / Timecode"
@classmethod
def poll(cls, context):
@ -778,12 +781,29 @@ class SEQUENCER_PT_proxy(SequencerButtonsPanel, Panel):
flow = layout.column_flow()
flow.prop(strip, "use_proxy_custom_directory")
flow.prop(strip, "use_proxy_custom_file")
if strip.proxy: # TODO - need to add this somehow
if strip.proxy:
if strip.use_proxy_custom_directory and not strip.use_proxy_custom_file:
flow.prop(strip.proxy, "directory")
if strip.use_proxy_custom_file:
flow.prop(strip.proxy, "filepath")
row = layout.row()
row.prop(strip.proxy, "build_25")
row.prop(strip.proxy, "build_50")
row.prop(strip.proxy, "build_75")
row.prop(strip.proxy, "build_100")
col = layout.column()
col.label(text="Build JPEG quality")
col.prop(strip.proxy, "quality")
if strip.type == "MOVIE":
col = layout.column()
col.label(text="Use timecode index:")
col.prop(strip.proxy, "timecode")
class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, Panel):
bl_label = "Scene Preview/Render"

@ -172,7 +172,9 @@ class TEXT_MT_text(Menu):
st = context.space_data
text = st.text
layout.operator_context = 'EXEC_AREA'
layout.operator("text.new")
layout.operator_context = 'INVOKE_AREA'
layout.operator("text.open")
if text:

@ -2080,9 +2080,11 @@ class VIEW3D_PT_view3d_properties(Panel):
col.prop(view, "lens")
col.label(text="Lock to Object:")
col.prop(view, "lock_object", text="")
if view.lock_object and view.lock_object.type == 'ARMATURE':
col.prop_search(view, "lock_bone", view.lock_object.data, "bones", text="")
elif not view.lock_object:
lock_object = view.lock_object
if lock_object:
if lock_object.type == 'ARMATURE':
col.prop_search(view, "lock_bone", lock_object.data, "edit_bones" if lock_object.mode == 'EDIT' else "bones", text="")
else:
col.prop(view, "lock_cursor", text="Lock to Cursor")
col = layout.column()

@ -87,17 +87,17 @@ unsigned int GET_TCC (FILE *fp) {
}
char *fcc_to_char (unsigned int fcc) {
DEBUG_FCC[0]= (fcc)&0177;
DEBUG_FCC[1]= (fcc>>8)&0177;
DEBUG_FCC[2]= (fcc>>16)&0177;
DEBUG_FCC[3]= (fcc>>24)&0177;
DEBUG_FCC[0]= (fcc)&127;
DEBUG_FCC[1]= (fcc>>8)&127;
DEBUG_FCC[2]= (fcc>>16)&127;
DEBUG_FCC[3]= (fcc>>24)&127;
return DEBUG_FCC;
}
char *tcc_to_char (unsigned int tcc) {
DEBUG_FCC[0]= (tcc)&0177;
DEBUG_FCC[1]= (tcc>>8)&0177;
DEBUG_FCC[0]= (tcc)&127;
DEBUG_FCC[1]= (tcc>>8)&127;
DEBUG_FCC[2]= 0;
DEBUG_FCC[3]= 0;

@ -283,7 +283,8 @@ struct DerivedMesh {
int (*setDrawOptions)(void *userData, int index,
int *drawSmooth_r),
void *userData, int useColors,
int (*setMaterial)(int, void *attribs));
int (*setMaterial)(int, void *attribs),
int (*compareDrawOptions)(void *userData, int cur_index, int next_index));
/* Draw mapped faces using MTFace
* o Drawing options too complicated to enumerate, look at code.

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

@ -60,7 +60,7 @@ int BKE_ftype_to_imtype(int ftype);
int BKE_imtype_to_ftype(int imtype);
int BKE_imtype_is_movie(int imtype);
struct anim *openanim(char * name, int flags);
struct anim *openanim(char * name, int flags, int streamindex);
void image_de_interlace(struct Image *ima, int odd);

@ -178,6 +178,7 @@ int seq_recursive_apply(struct Sequence *seq, int (*apply_func)(struct Sequence
/* maintainance functions, mostly for RNA */
// extern
void seq_free_sequence(struct Scene *scene, struct Sequence *seq);
void seq_free_sequence_recurse(struct Scene *scene, struct Sequence *seq);
void seq_free_strip(struct Strip *strip);
void seq_free_editing(struct Scene *scene);
void seq_free_clipboard(void);
@ -200,6 +201,11 @@ void update_changed_seq_and_deps(struct Scene *scene, struct Sequence *changed_s
int input_have_to_preprocess(
SeqRenderData context, struct Sequence * seq, float cfra);
void seq_proxy_rebuild(struct Main * bmain,
struct Scene *scene, struct Sequence * seq,
short *stop, short *do_update, float *progress);
/* **********************************************************************
seqcache.c

@ -637,7 +637,8 @@ static void emDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *use
}
/* note, material function is ignored for now. */
static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int UNUSED(useColors), int (*setMaterial)(int, void *attribs))
static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int UNUSED(useColors), int (*setMaterial)(int, void *attribs),
int (*compareDrawOptions)(void *userData, int cur_index, int next_index))
{
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
EditFace *efa;
@ -645,6 +646,9 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
(void)setMaterial; /* unused */
/* currently unused -- each original face is handled separately */
(void)compareDrawOptions;
if (emdm->vertexCos) {
EditVert *eve;

@ -1348,6 +1348,10 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
continue;
if(part->ren_as==PART_DRAW_GR) {
/* prevent divide by zero below [#28336] */
if(totgroup == 0)
continue;
/* for groups, pick the object based on settings */
if(part->draw&PART_DRAW_RAND_GR)
b= BLI_rand() % totgroup;

@ -843,7 +843,8 @@ static void cdDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tfa
cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, NULL);
}
static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs))
static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs),
int (*compareDrawOptions)(void *userData, int cur_index, int next_index))
{
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
MVert *mv = cddm->mvert;
@ -958,6 +959,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
MFace *mface= mf + actualFace;
int drawSmooth= (mface->flag & ME_SMOOTH);
int draw = 1;
int flush = 0;
if(i != tottri-1)
next_actualFace= dm->drawObject->triangle_to_mface[i+1];
@ -972,11 +974,28 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
/* Goal is to draw as long of a contiguous triangle
array as possible, so draw when we hit either an
invisible triangle or at the end of the array */
if(!draw || i == tottri - 1 || mf[actualFace].mat_nr != mf[next_actualFace].mat_nr) {
if(prevstart != i)
/* Add one to the length (via `draw')
if we're drawing at the end of the array */
glDrawArrays(GL_TRIANGLES,prevstart*3, (i-prevstart+draw)*3);
/* flush buffer if current triangle isn't drawable or it's last triangle... */
flush= !draw || i == tottri - 1;
/* ... or when material setting is dissferent */
flush|= mf[actualFace].mat_nr != mf[next_actualFace].mat_nr;
if(!flush && compareDrawOptions) {
int next_orig= (index==NULL) ? next_actualFace : index[next_actualFace];
/* also compare draw options and flush buffer if they're different
need for face selection highlight in edit mode */
flush|= compareDrawOptions(userData, orig, next_orig) == 0;
}
if(flush) {
int first= prevstart*3;
int count= (i-prevstart+(draw ? 1 : 0))*3; /* Add one to the length if we're drawing at the end of the array */
if(count)
glDrawArrays(GL_TRIANGLES, first, count);
prevstart = i + 1;
}
}

@ -1371,15 +1371,15 @@ void BKE_makepicstring(char *string, const char *base, int frame, int imtype, co
}
/* used by sequencer too */
struct anim *openanim(char *name, int flags)
struct anim *openanim(char *name, int flags, int streamindex)
{
struct anim *anim;
struct ImBuf *ibuf;
anim = IMB_open_anim(name, flags);
anim = IMB_open_anim(name, flags, streamindex);
if (anim == NULL) return NULL;
ibuf = IMB_anim_absolute(anim, 0);
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
if (ibuf == NULL) {
if(BLI_exists(name))
printf("not an anim: %s\n", name);
@ -1773,20 +1773,26 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
else
BLI_path_abs(str, G.main->name);
ima->anim = openanim(str, IB_rect);
/* FIXME: make several stream accessible in image editor, too*/
ima->anim = openanim(str, IB_rect, 0);
/* let's initialize this user */
if(ima->anim && iuser && iuser->frames==0)
iuser->frames= IMB_anim_get_duration(ima->anim);
iuser->frames= IMB_anim_get_duration(ima->anim,
IMB_TC_RECORD_RUN);
}
if(ima->anim) {
int dur = IMB_anim_get_duration(ima->anim);
int dur = IMB_anim_get_duration(ima->anim,
IMB_TC_RECORD_RUN);
int fra= frame-1;
if(fra<0) fra = 0;
if(fra>(dur-1)) fra= dur-1;
ibuf = IMB_anim_absolute(ima->anim, fra);
ibuf = IMB_makeSingleUser(
IMB_anim_absolute(ima->anim, fra,
IMB_TC_RECORD_RUN,
IMB_PROXY_NONE));
if(ibuf) {
image_initialize_after_load(ima, ibuf);

@ -715,7 +715,7 @@ void *copy_libblock(void *rt)
assert(idn != NULL);
idn_len= MEM_allocN_len(idn);
if(idn_len - sizeof(ID) > 0) {
if((int)idn_len - (int)sizeof(ID) > 0) { /* signed to allow neg result */
cp= (char *)id;
cpn= (char *)idn;
memcpy(cpn+sizeof(ID), cp+sizeof(ID), idn_len - sizeof(ID));

@ -515,7 +515,7 @@ short *give_totcolp_id(ID *id)
return NULL;
}
void data_delete_material_index_id(ID *id, int index)
static void data_delete_material_index_id(ID *id, int index)
{
switch(GS(id->name)) {
case ID_ME:
@ -1365,7 +1365,7 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col)
}
/* copy/paste buffer, if we had a propper py api that would be better */
Material matcopybuf;
static Material matcopybuf;
static short matcopied= 0;
void clear_matcopybuf(void)

@ -80,7 +80,7 @@ static void edge_store_from_mface_quad(EdgeUUID es[4], MFace *mf)
edge_store_assign(es[3].verts, mf->v4, mf->v1);
}
static void edge_store_from_mface_tri(EdgeUUID es[3], MFace *mf)
static void edge_store_from_mface_tri(EdgeUUID es[4], MFace *mf)
{
edge_store_assign(es[0].verts, mf->v1, mf->v2);
edge_store_assign(es[1].verts, mf->v2, mf->v3);
@ -143,30 +143,30 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), unsigned int totve
BLI_assert(!(do_fixes && me == NULL));
PRINT("ED_mesh_validate: verts(%d), edges(%d), faces(%d)\n", totvert, totedge, totface);
PRINT("ED_mesh_validate: verts(%u), edges(%u), faces(%u)\n", totvert, totedge, totface);
if(totedge == 0 && totface != 0) {
PRINT(" locical error, %d faces and 0 edges\n", totface);
PRINT(" locical error, %u faces and 0 edges\n", totface);
do_edge_recalc= TRUE;
}
for(i=0, med= medges; i<totedge; i++, med++) {
int remove= FALSE;
if(med->v1 == med->v2) {
PRINT(" edge %d: has matching verts, both %d\n", i, med->v1);
PRINT(" edge %u: has matching verts, both %u\n", i, med->v1);
remove= do_fixes;
}
if(med->v1 >= totvert) {
PRINT(" edge %d: v1 index out of range, %d\n", i, med->v1);
PRINT(" edge %u: v1 index out of range, %u\n", i, med->v1);
remove= do_fixes;
}
if(med->v2 >= totvert) {
PRINT(" edge %d: v2 index out of range, %d\n", i, med->v2);
PRINT(" edge %u: v2 index out of range, %u\n", i, med->v2);
remove= do_fixes;
}
if(BLI_edgehash_haskey(edge_hash, med->v1, med->v2)) {
PRINT(" edge %d: is a duplicate of, %d\n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, med->v1, med->v2)));
PRINT(" edge %u: is a duplicate of, %u\n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, med->v1, med->v2)));
remove= do_fixes;
}
@ -187,41 +187,41 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), unsigned int totve
do {
fv[fidx]= *(&(mf->v1) + fidx);
if(fv[fidx] >= totvert) {
PRINT(" face %d: 'v%d' index out of range, %d\n", i, fidx + 1, fv[fidx]);
PRINT(" face %u: 'v%d' index out of range, %u\n", i, fidx + 1, fv[fidx]);
remove= do_fixes;
}
} while (fidx--);
if(remove == FALSE) {
if(mf->v4) {
if(mf->v1 == mf->v2) { PRINT(" face %d: verts invalid, v1/v2 both %d\n", i, mf->v1); remove= do_fixes; }
if(mf->v1 == mf->v3) { PRINT(" face %d: verts invalid, v1/v3 both %d\n", i, mf->v1); remove= do_fixes; }
if(mf->v1 == mf->v4) { PRINT(" face %d: verts invalid, v1/v4 both %d\n", i, mf->v1); remove= do_fixes; }
if(mf->v1 == mf->v2) { PRINT(" face %u: verts invalid, v1/v2 both %u\n", i, mf->v1); remove= do_fixes; }
if(mf->v1 == mf->v3) { PRINT(" face %u: verts invalid, v1/v3 both %u\n", i, mf->v1); remove= do_fixes; }
if(mf->v1 == mf->v4) { PRINT(" face %u: verts invalid, v1/v4 both %u\n", i, mf->v1); remove= do_fixes; }
if(mf->v2 == mf->v3) { PRINT(" face %d: verts invalid, v2/v3 both %d\n", i, mf->v2); remove= do_fixes; }
if(mf->v2 == mf->v4) { PRINT(" face %d: verts invalid, v2/v4 both %d\n", i, mf->v2); remove= do_fixes; }
if(mf->v2 == mf->v3) { PRINT(" face %u: verts invalid, v2/v3 both %u\n", i, mf->v2); remove= do_fixes; }
if(mf->v2 == mf->v4) { PRINT(" face %u: verts invalid, v2/v4 both %u\n", i, mf->v2); remove= do_fixes; }
if(mf->v3 == mf->v4) { PRINT(" face %d: verts invalid, v3/v4 both %d\n", i, mf->v3); remove= do_fixes; }
if(mf->v3 == mf->v4) { PRINT(" face %u: verts invalid, v3/v4 both %u\n", i, mf->v3); remove= do_fixes; }
}
else {
if(mf->v1 == mf->v2) { PRINT(" faceT %d: verts invalid, v1/v2 both %d\n", i, mf->v1); remove= do_fixes; }
if(mf->v1 == mf->v3) { PRINT(" faceT %d: verts invalid, v1/v3 both %d\n", i, mf->v1); remove= do_fixes; }
if(mf->v1 == mf->v2) { PRINT(" faceT %u: verts invalid, v1/v2 both %u\n", i, mf->v1); remove= do_fixes; }
if(mf->v1 == mf->v3) { PRINT(" faceT %u: verts invalid, v1/v3 both %u\n", i, mf->v1); remove= do_fixes; }
if(mf->v2 == mf->v3) { PRINT(" faceT %d: verts invalid, v2/v3 both %d\n", i, mf->v2); remove= do_fixes; }
if(mf->v2 == mf->v3) { PRINT(" faceT %u: verts invalid, v2/v3 both %u\n", i, mf->v2); remove= do_fixes; }
}
if(remove == FALSE) {
if(totedge) {
if(mf->v4) {
if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) { PRINT(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); do_edge_recalc= TRUE; }
if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) { PRINT(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); do_edge_recalc= TRUE; }
if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v4)) { PRINT(" face %d: edge v3/v4 (%d,%d) is missing egde data\n", i, mf->v3, mf->v4); do_edge_recalc= TRUE; }
if(!BLI_edgehash_haskey(edge_hash, mf->v4, mf->v1)) { PRINT(" face %d: edge v4/v1 (%d,%d) is missing egde data\n", i, mf->v4, mf->v1); do_edge_recalc= TRUE; }
if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) { PRINT(" face %u: edge v1/v2 (%u,%u) is missing egde data\n", i, mf->v1, mf->v2); do_edge_recalc= TRUE; }
if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) { PRINT(" face %u: edge v2/v3 (%u,%u) is missing egde data\n", i, mf->v2, mf->v3); do_edge_recalc= TRUE; }
if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v4)) { PRINT(" face %u: edge v3/v4 (%u,%u) is missing egde data\n", i, mf->v3, mf->v4); do_edge_recalc= TRUE; }
if(!BLI_edgehash_haskey(edge_hash, mf->v4, mf->v1)) { PRINT(" face %u: edge v4/v1 (%u,%u) is missing egde data\n", i, mf->v4, mf->v1); do_edge_recalc= TRUE; }
}
else {
if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) { PRINT(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); do_edge_recalc= TRUE; }
if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) { PRINT(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); do_edge_recalc= TRUE; }
if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v1)) { PRINT(" face %d: edge v3/v1 (%d,%d) is missing egde data\n", i, mf->v3, mf->v1); do_edge_recalc= TRUE; }
if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) { PRINT(" face %u: edge v1/v2 (%u,%u) is missing egde data\n", i, mf->v1, mf->v2); do_edge_recalc= TRUE; }
if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) { PRINT(" face %u: edge v2/v3 (%u,%u) is missing egde data\n", i, mf->v2, mf->v3); do_edge_recalc= TRUE; }
if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v1)) { PRINT(" face %u: edge v3/v1 (%u,%u) is missing egde data\n", i, mf->v3, mf->v1); do_edge_recalc= TRUE; }
}
}
@ -261,10 +261,10 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), unsigned int totve
if(do_verbose) {
mf_prev= mfaces + sf_prev->index;
if(mf->v4) {
PRINT(" face %d & %d: are duplicates (%d,%d,%d,%d) (%d,%d,%d,%d)\n", sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, mf->v4, mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4);
PRINT(" face %u & %u: are duplicates (%u,%u,%u,%u) (%u,%u,%u,%u)\n", sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, mf->v4, mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4);
}
else {
PRINT(" face %d & %d: are duplicates (%d,%d,%d) (%d,%d,%d)\n", sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, mf_prev->v1, mf_prev->v2, mf_prev->v3);
PRINT(" face %u & %u: are duplicates (%u,%u,%u) (%u,%u,%u)\n", sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, mf_prev->v1, mf_prev->v2, mf_prev->v3);
}
}

@ -1537,6 +1537,7 @@ void multires_load_old(Object *ob, Mesh *me)
me->mface[i].v2 = lvl->faces[i].v[1];
me->mface[i].v3 = lvl->faces[i].v[2];
me->mface[i].v4 = lvl->faces[i].v[3];
me->mface[i].mat_nr = lvl->faces[i].mat_nr;
}
/* Add a multires modifier to the object */

@ -3138,7 +3138,7 @@ int object_is_modified(Scene *scene, Object *ob)
int flag= 0;
if(ob_get_key(ob)) {
flag |= eModifierMode_Render | eModifierMode_Render;
flag |= eModifierMode_Render;
}
else {
ModifierData *md;

@ -3161,7 +3161,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
}
else {
ca->vel[0] = ca->vel[1] = 0.0f;
ca->vel[1] = 1.0f;
ca->vel[2] = 1.0f;
}
/* selection coloring in edit mode */

@ -967,12 +967,12 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
if(pid->cache->flag & PTCACHE_EXTERNAL) {
if(pid->cache->index >= 0)
snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02d"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */
snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */
else
snprintf(newname, MAX_PTCACHE_FILE, "_%06d"PTCACHE_EXT, cfra); /* always 6 chars */
}
else {
snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02d"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */
snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */
}
len += 16;
}
@ -2002,7 +2002,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
if (dir==NULL)
return;
snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, pid->stack_index);
snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index);
while ((de = readdir(dir)) != NULL) {
if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
@ -2204,7 +2204,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
if (dir==NULL)
return;
snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, pid->stack_index);
snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index);
while ((de = readdir(dir)) != NULL) {
if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
@ -2904,7 +2904,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to)
return;
}
snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, pid->stack_index);
snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index);
/* put new name into cache */
strcpy(pid->cache->name, to);

@ -2029,16 +2029,11 @@ static void init_transform_effect(Sequence *seq)
transform->ScalexIni = 1.0f;
transform->ScaleyIni = 1.0f;
transform->ScalexFin = 1.0f;
transform->ScalexFin = 1.0f;
transform->xIni=0.0f;
transform->xFin=0.0f;
transform->yIni=0.0f;
transform->yFin=0.0f;
transform->rotIni=0.0f;
transform->rotFin=0.0f;
transform->interpolation=1;
transform->percent=1;
@ -2878,7 +2873,7 @@ static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq,
{
Editing * ed;
ListBase * seqbasep;
struct ImBuf * i = 0;
struct ImBuf * i= NULL;
ed = context.scene->ed;
@ -2913,7 +2908,7 @@ static struct ImBuf * do_adjustment(
struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2),
struct ImBuf *UNUSED(ibuf3))
{
struct ImBuf * i = 0;
struct ImBuf * i = NULL;
struct ImBuf * out;
Editing * ed;

@ -218,6 +218,18 @@ void seq_free_sequence(Scene *scene, Sequence *seq)
MEM_freeN(seq);
}
void seq_free_sequence_recurse(Scene *scene, Sequence *seq)
{
Sequence *iseq;
for(iseq= seq->seqbase.first; iseq; iseq= iseq->next) {
seq_free_sequence_recurse(scene, iseq);
}
seq_free_sequence(scene, seq);
}
Editing *seq_give_editing(Scene *scene, int alloc)
{
if (scene->ed == NULL && alloc) {
@ -683,13 +695,16 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range)
}
case SEQ_MOVIE:
if(seq->anim) IMB_free_anim(seq->anim);
seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0));
seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex);
if (!seq->anim) {
return;
}
seq->len = IMB_anim_get_duration(seq->anim);
seq->len = IMB_anim_get_duration(seq->anim,
seq->strip->proxy ?
seq->strip->proxy->tc :
IMB_TC_RECORD_RUN);
seq->anim_preseek = IMB_anim_get_preseek(seq->anim);
@ -1117,7 +1132,7 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se
return cnt;
}
/* **********************************************************************
proxy management
@ -1125,48 +1140,105 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se
#define PROXY_MAXFILE (2*FILE_MAXDIR+FILE_MAXFILE)
static IMB_Proxy_Size seq_rendersize_to_proxysize(int size)
{
if (size >= 100) {
return IMB_PROXY_NONE;
}
if (size >= 99) {
return IMB_PROXY_100;
}
if (size >= 75) {
return IMB_PROXY_75;
}
if (size >= 50) {
return IMB_PROXY_50;
}
return IMB_PROXY_25;
}
static void seq_open_anim_file(Sequence * seq)
{
char name[FILE_MAXDIR+FILE_MAXFILE];
StripProxy * proxy;
if(seq->anim != NULL) {
return;
}
BLI_join_dirfile(name, sizeof(name),
seq->strip->dir, seq->strip->stripdata->name);
BLI_path_abs(name, G.main->name);
seq->anim = openanim(name, IB_rect |
((seq->flag & SEQ_FILTERY) ?
IB_animdeinterlace : 0), seq->streamindex);
if (seq->anim == NULL) {
return;
}
proxy = seq->strip->proxy;
if (proxy == NULL) {
return;
}
if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) {
IMB_anim_set_index_dir(seq->anim, seq->strip->proxy->dir);
}
}
static int seq_proxy_get_fname(SeqRenderData context, Sequence * seq, int cfra, char * name)
{
int frameno;
char dir[FILE_MAXDIR];
int render_size = context.preview_render_size;
if (!seq->strip->proxy) {
return FALSE;
}
/* MOVIE tracks (only exception: custom files) are now handled
internally by ImBuf module for various reasons: proper time code
support, quicker index build, using one file instead
of a full directory of jpeg files, etc. Trying to support old
and new method at once could lead to funny effects, if people
have both, a directory full of jpeg files and proxy avis, so
sorry folks, please rebuild your proxies... */
if (seq->flag & (SEQ_USE_PROXY_CUSTOM_DIR|SEQ_USE_PROXY_CUSTOM_FILE)) {
strcpy(dir, seq->strip->proxy->dir);
} else if (seq->type == SEQ_IMAGE) {
snprintf(dir, PROXY_MAXFILE, "%s/BL_proxy", seq->strip->dir);
} else {
if (ELEM(seq->type, SEQ_IMAGE, SEQ_MOVIE)) {
snprintf(dir, FILE_MAXDIR, "%s/BL_proxy", seq->strip->dir);
} else {
return FALSE;
}
return FALSE;
}
if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
BLI_join_dirfile(name, FILE_MAX, dir, seq->strip->proxy->file); /* XXX, not real length */
BLI_join_dirfile(name, PROXY_MAXFILE,
dir, seq->strip->proxy->file);
BLI_path_abs(name, G.main->name);
return TRUE;
}
/* dirty hack to distinguish 100% render size from PROXY_100 */
if (render_size == 99) {
render_size = 100;
}
/* generate a separate proxy directory for each preview size */
switch(seq->type) {
case SEQ_IMAGE:
if (seq->type == SEQ_IMAGE) {
snprintf(name, PROXY_MAXFILE, "%s/images/%d/%s_proxy", dir,
context.preview_render_size,
give_stripelem(seq, cfra)->name);
frameno = 1;
break;
case SEQ_MOVIE:
frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs;
snprintf(name, PROXY_MAXFILE, "%s/%s/%d/####", dir,
seq->strip->stripdata->name, context.preview_render_size);
break;
default:
frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs;
} else {
frameno = (int) give_stripelem_index(seq, cfra)
+ seq->anim_startofs;
snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir,
context.preview_render_size);
}
@ -1182,13 +1254,18 @@ static int seq_proxy_get_fname(SeqRenderData context, Sequence * seq, int cfra,
static struct ImBuf * seq_proxy_fetch(SeqRenderData context, Sequence * seq, int cfra)
{
char name[PROXY_MAXFILE];
IMB_Proxy_Size psize = seq_rendersize_to_proxysize(
context.preview_render_size);
int size_flags;
if (!(seq->flag & SEQ_USE_PROXY)) {
return NULL;
}
/* rendering at 100% ? No real sense in proxy-ing, right? */
if (context.preview_render_size == 100) {
size_flags = seq->strip->proxy->build_size_flags;
/* only use proxies, if they are enabled (even if present!) */
if (psize != IMB_PROXY_NONE && ((size_flags & psize) != psize)) {
return NULL;
}
@ -1199,13 +1276,19 @@ static struct ImBuf * seq_proxy_fetch(SeqRenderData context, Sequence * seq, int
return NULL;
}
seq->strip->proxy->anim = openanim(name, IB_rect);
seq->strip->proxy->anim = openanim(name, IB_rect, 0);
}
if (seq->strip->proxy->anim==NULL) {
return NULL;
}
return IMB_anim_absolute(seq->strip->proxy->anim, frameno);
seq_open_anim_file(seq);
frameno = IMB_anim_index_get_frame_index(
seq->anim, seq->strip->proxy->tc, frameno);
return IMB_anim_absolute(seq->strip->proxy->anim, frameno,
IMB_TC_NONE, IMB_PROXY_NONE);
}
if (seq_proxy_get_fname(context, seq, cfra, name) == 0) {
@ -1219,67 +1302,30 @@ static struct ImBuf * seq_proxy_fetch(SeqRenderData context, Sequence * seq, int
}
}
#if 0
static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra,
int build_proxy_run, int preview_render_size);
static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int preview_render_size, int seqrectx, int seqrecty)
static void seq_proxy_build_frame(SeqRenderData context,
Sequence* seq, int cfra,
int proxy_render_size)
{
char name[PROXY_MAXFILE];
int quality;
TStripElem * se;
int ok;
int rectx, recty;
int ok;
struct ImBuf * ibuf;
if (!(seq->flag & SEQ_USE_PROXY)) {
if (!seq_proxy_get_fname(context, seq, cfra, name)) {
return;
}
/* rendering at 100% ? No real sense in proxy-ing, right? */
if (preview_render_size == 100) {
return;
}
ibuf = seq_render_strip(context, seq, cfra);
/* that's why it is called custom... */
if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
return;
}
if (!seq_proxy_get_fname(scene, seq, cfra, name, preview_render_size)) {
return;
}
se = give_tstripelem(seq, cfra);
if (!se) {
return;
}
if(se->ibuf) {
IMB_freeImBuf(se->ibuf);
se->ibuf = 0;
}
do_build_seq_ibuf(scene, seq, se, cfra, TRUE, preview_render_size,
seqrectx, seqrecty);
if (!se->ibuf) {
return;
}
rectx= (preview_render_size*scene->r.xsch)/100;
recty= (preview_render_size*scene->r.ysch)/100;
ibuf = se->ibuf;
rectx = (proxy_render_size * context.scene->r.xsch) / 100;
recty = (proxy_render_size * context.scene->r.ysch) / 100;
if (ibuf->x != rectx || ibuf->y != recty) {
IMB_scalefastImBuf(ibuf, (short)rectx, (short)recty);
}
/* quality is fixed, otherwise one has to generate separate
directories for every quality...
depth = 32 is intentionally left in, otherwise ALPHA channels
/* depth = 32 is intentionally left in, otherwise ALPHA channels
won't work... */
quality = seq->strip->proxy->quality;
ibuf->ftype= JPG | quality;
@ -1292,69 +1338,80 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int pr
}
IMB_freeImBuf(ibuf);
se->ibuf = 0;
}
static void seq_proxy_rebuild(Scene *scene, Sequence * seq, int seqrectx,
int seqrecty)
void seq_proxy_rebuild(struct Main * bmain, Scene *scene, Sequence * seq,
short *stop, short *do_update, float *progress)
{
SeqRenderData context;
int cfra;
float rsize = seq->strip->proxy->size;
int tc_flags;
int size_flags;
int quality;
waitcursor(1);
G.afbreek = 0;
/* flag management tries to account for strobe and
other "non-linearities", that might come in the future...
better way would be to "touch" the files, so that _really_
no one is rebuild twice.
*/
for (cfra = seq->startdisp; cfra < seq->enddisp; cfra++) {
TStripElem * tse = give_tstripelem(seq, cfra);
tse->flag &= ~STRIPELEM_PREVIEW_DONE;
if (!seq->strip || !seq->strip->proxy) {
return;
}
/* a _lot_ faster for movie files, if we read frames in
sequential order */
if (seq->flag & SEQ_REVERSE_FRAMES) {
for (cfra = seq->enddisp-seq->endstill-1;
cfra >= seq->startdisp + seq->startstill; cfra--) {
TStripElem * tse = give_tstripelem(seq, cfra);
if (!(tse->flag & STRIPELEM_PREVIEW_DONE)) {
//XXX set_timecursor(cfra);
seq_proxy_build_frame(scene, seq, cfra, rsize,
seqrectx, seqrecty);
tse->flag |= STRIPELEM_PREVIEW_DONE;
}
if (blender_test_break()) {
break;
}
}
} else {
for (cfra = seq->startdisp + seq->startstill;
cfra < seq->enddisp - seq->endstill; cfra++) {
TStripElem * tse = give_tstripelem(seq, cfra);
if (!(tse->flag & STRIPELEM_PREVIEW_DONE)) {
//XXX set_timecursor(cfra);
seq_proxy_build_frame(scene, seq, cfra, rsize,
seqrectx, seqrecty);
tse->flag |= STRIPELEM_PREVIEW_DONE;
}
if (blender_test_break()) {
break;
}
}
if (!(seq->flag & SEQ_USE_PROXY)) {
return;
}
tc_flags = seq->strip->proxy->build_tc_flags;
size_flags = seq->strip->proxy->build_size_flags;
quality = seq->strip->proxy->quality;
if (seq->type == SEQ_MOVIE) {
seq_open_anim_file(seq);
if (seq->anim) {
IMB_anim_index_rebuild(
seq->anim, tc_flags, size_flags, quality,
stop, do_update, progress);
}
return;
}
if (!(seq->flag & SEQ_USE_PROXY)) {
return;
}
/* that's why it is called custom... */
if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
return;
}
/* fail safe code */
context = seq_new_render_data(
bmain, scene,
(scene->r.size * (float) scene->r.xsch) / 100.0f + 0.5f,
(scene->r.size * (float) scene->r.ysch) / 100.0f + 0.5f,
100);
for (cfra = seq->startdisp + seq->startstill;
cfra < seq->enddisp - seq->endstill; cfra++) {
if (size_flags & IMB_PROXY_25) {
seq_proxy_build_frame(context, seq, cfra, 25);
}
if (size_flags & IMB_PROXY_50) {
seq_proxy_build_frame(context, seq, cfra, 50);
}
if (size_flags & IMB_PROXY_75) {
seq_proxy_build_frame(context, seq, cfra, 75);
}
if (size_flags & IMB_PROXY_100) {
seq_proxy_build_frame(context, seq, cfra, 100);
}
*progress= (float)cfra/(seq->enddisp - seq->endstill
- seq->startdisp + seq->startstill);
*do_update= 1;
if(*stop || G.afbreek)
break;
}
waitcursor(0);
}
#endif
/* **********************************************************************
@ -1571,6 +1628,8 @@ static ImBuf * input_preprocess(
{
float mul;
ibuf = IMB_makeSingleUser(ibuf);
if((seq->flag & SEQ_FILTERY) && seq->type != SEQ_MOVIE) {
IMB_filtery(ibuf);
}
@ -2096,17 +2155,20 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr
}
case SEQ_MOVIE:
{
if(seq->anim==NULL) {
BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name);
BLI_path_abs(name, G.main->name);
seq->anim = openanim(name, IB_rect |
((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0));
}
seq_open_anim_file(seq);
if(seq->anim) {
IMB_anim_set_preseek(seq->anim, seq->anim_preseek);
ibuf = IMB_anim_absolute(seq->anim, nr + seq->anim_startofs);
IMB_anim_set_preseek(seq->anim,
seq->anim_preseek);
ibuf = IMB_anim_absolute(
seq->anim, nr + seq->anim_startofs,
seq->strip->proxy ?
seq->strip->proxy->tc
: IMB_TC_RECORD_RUN,
seq_rendersize_to_proxysize(
context.preview_render_size));
/* we don't need both (speed reasons)! */
if (ibuf && ibuf->rect_float && ibuf->rect)
imb_freerectImBuf(ibuf);
@ -3625,7 +3687,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
BLI_strncpy(path, seq_load->path, sizeof(path));
BLI_path_abs(path, G.main->name);
an = openanim(path, IB_rect);
an = openanim(path, IB_rect, 0);
if(an==NULL)
return NULL;
@ -3641,7 +3703,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
/* basic defaults */
seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
strip->len = seq->len = IMB_anim_get_duration( an );
strip->len = seq->len = IMB_anim_get_duration( an, IMB_TC_RECORD_RUN );
strip->us= 1;
/* we only need 1 element for MOVIE strips */

@ -1779,7 +1779,8 @@ static void ccgDM_drawUVEdges(DerivedMesh *dm)
}
}
static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs)) {
static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs),
int (*compareDrawOptions)(void *userData, int cur_index, int next_index)) {
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
CCGSubSurf *ss = ccgdm->ss;
MCol *mcol= NULL;
@ -1787,6 +1788,9 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *u
char *faceFlags = ccgdm->faceFlags;
int gridFaces = gridSize - 1, totface;
/* currently unused -- each original face is handled separately */
(void)compareDrawOptions;
if(useColors) {
mcol = dm->getFaceDataArray(dm, CD_WEIGHT_MCOL);
if(!mcol)

@ -107,9 +107,6 @@ void mat4_to_axis_angle(float axis[3], float *angle, float M[4][4]);
/* TODO: the following calls should probably be depreceated sometime */
/* conversion */
void mat3_to_vec_rot(float vec[3], float *phi, float mat[3][3]);
void mat4_to_vec_rot(float vec[3], float *phi, float mat[4][4]);
void vec_rot_to_quat(float quat[4], const float vec[3], const float phi);
void vec_rot_to_mat3(float mat[3][3], const float vec[3], const float phi);
void vec_rot_to_mat4(float mat[4][4], const float vec[3], const float phi);

@ -99,7 +99,7 @@ MINLINE float dot_v3v3(const float a[3], const float b[3]);
MINLINE float cross_v2v2(const float a[2], const float b[2]);
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]);
MINLINE void star_m3_v3(float R[3][3],float a[3]);
MINLINE void star_m3_v3(float rmat[3][3],float a[3]);
/*********************************** Length **********************************/
@ -133,7 +133,7 @@ MINLINE int is_zero_v3(const float a[3]);
MINLINE int is_zero_v4(const float a[4]);
MINLINE int is_one_v3(const float a[3]);
MINLINE int equals_v2v2(const float *v1, const float *v2);
MINLINE int equals_v2v2(const float v1[2], const float v2[2]);
MINLINE int equals_v3v3(const float a[3], const float b[3]);
MINLINE int compare_v3v3(const float a[3], const float b[3], const float limit);
MINLINE int compare_len_v3v3(const float a[3], const float b[3], const float limit);

@ -122,6 +122,8 @@ __attribute__ ((format (printf, 1, 2)))
#endif
;
size_t BLI_strescape(char *dst, const char *src, const size_t maxlen);
/**
* Compare two strings without regard to case.
*

@ -105,9 +105,9 @@
#define FTOUSHORT(val) ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f))
#define F3TOCHAR3(v2,v1) (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); (v1)[2]=FTOCHAR((v2[2]))
#define F3TOCHAR4(v2,v1) { (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); (v1)[2]=FTOCHAR((v2[2])); \
(v1)[3]=FTOCHAR((v2[3])); (v1)[3] = 255; }
(v1)[3] = 255; }
#define F4TOCHAR4(v2,v1) { (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); (v1)[2]=FTOCHAR((v2[2])); \
(v1)[3]=FTOCHAR((v2[3])); (v1)[3]=FTOCHAR((v2[3])); }
(v1)[3]=FTOCHAR((v2[3])); }
#define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}

@ -40,7 +40,7 @@
#include "BLO_sys_types.h" // for intptr_t support
/***/
unsigned int hashsizes[]= {
static unsigned int hashsizes[]= {
5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209,
16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169,
4194319, 8388617, 16777259, 33554467, 67108879, 134217757,

@ -28,7 +28,7 @@
#include "MEM_guardedalloc.h"
static ListBase callback_slots[BLI_CB_EVT_TOT]= {{0}};
static ListBase callback_slots[BLI_CB_EVT_TOT]= {{NULL}};
void BLI_exec_cb(struct Main *main, struct ID *self, eCbEvent evt)
{

@ -69,8 +69,10 @@ int BLI_gzip(const char *from, const char *to) {
int readsize = 0;
int rval= 0, err;
gzFile gzfile;
gzfile = gzopen(to, "wb");
/* level 1 is very close to 3 (the default) in terms of file size,
* but about twice as fast, best use for speedy saving - campbell */
gzfile = gzopen(to, "wb1");
if(gzfile == NULL)
return -1;

@ -774,28 +774,6 @@ void mat4_to_axis_angle(float axis[3], float *angle,float mat[4][4])
/****************************** Vector/Rotation ******************************/
/* TODO: the following calls should probably be depreceated sometime */
/* 3x3 matrix to axis angle */
void mat3_to_vec_rot(float axis[3], float *angle,float mat[3][3])
{
float q[4];
/* use quaternions as intermediate representation */
// TODO: it would be nicer to go straight there...
mat3_to_quat(q,mat);
quat_to_axis_angle(axis, angle,q);
}
/* 4x4 matrix to axis angle */
void mat4_to_vec_rot(float axis[3], float *angle,float mat[4][4])
{
float q[4];
/* use quaternions as intermediate representation */
// TODO: it would be nicer to go straight there...
mat4_to_quat(q,mat);
quat_to_axis_angle(axis, angle,q);
}
/* axis angle to 3x3 matrix */
void vec_rot_to_mat3(float mat[][3], const float vec[3], const float phi)
{

@ -136,26 +136,26 @@ MINLINE void add_v3_v3(float *r, const float *a)
r[2] += a[2];
}
MINLINE void add_v3_v3v3(float *r, const float *a, const float *b)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
{
r[0]= a[0] + b[0];
r[1]= a[1] + b[1];
r[2]= a[2] + b[2];
}
MINLINE void sub_v2_v2(float *r, const float *a)
MINLINE void sub_v2_v2(float r[2], const float a[2])
{
r[0] -= a[0];
r[1] -= a[1];
}
MINLINE void sub_v2_v2v2(float *r, const float *a, const float *b)
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
{
r[0]= a[0] - b[0];
r[1]= a[1] - b[1];
}
MINLINE void sub_v3_v3(float *r, const float *a)
MINLINE void sub_v3_v3(float r[3], const float a[3])
{
r[0] -= a[0];
r[1] -= a[1];
@ -177,7 +177,7 @@ MINLINE void sub_v4_v4(float r[4], const float a[4])
r[3] -= a[3];
}
MINLINE void sub_v4_v4v4(float r[3], const float a[3], const float b[3])
MINLINE void sub_v4_v4v4(float r[4], const float a[4], const float b[4])
{
r[0]= a[0] - b[0];
r[1]= a[1] - b[1];
@ -186,10 +186,10 @@ MINLINE void sub_v4_v4v4(float r[3], const float a[3], const float b[3])
}
MINLINE void mul_v2_fl(float *v1, float f)
MINLINE void mul_v2_fl(float r[2], float f)
{
v1[0]*= f;
v1[1]*= f;
r[0]*= f;
r[1]*= f;
}
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
@ -281,11 +281,11 @@ MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
r[3] += a[3]*f;
}
MINLINE void mul_v3_v3v3(float *v, const float *v1, const float *v2)
MINLINE void mul_v3_v3v3(float r[3], const float v1[3], const float v2[3])
{
v[0] = v1[0] * v2[0];
v[1] = v1[1] * v2[1];
v[2] = v1[2] * v2[2];
r[0] = v1[0] * v2[0];
r[1] = v1[1] * v2[1];
r[2] = v1[2] * v2[2];
}
MINLINE void negate_v3(float r[3])
@ -340,15 +340,15 @@ MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
r[2]= a[0]*b[1] - a[1]*b[0];
}
MINLINE void star_m3_v3(float mat[][3], float *vec)
MINLINE void star_m3_v3(float rmat[][3], float a[3])
{
mat[0][0]= mat[1][1]= mat[2][2]= 0.0;
mat[0][1]= -vec[2];
mat[0][2]= vec[1];
mat[1][0]= vec[2];
mat[1][2]= -vec[0];
mat[2][0]= -vec[1];
mat[2][1]= vec[0];
rmat[0][0]= rmat[1][1]= rmat[2][2]= 0.0;
rmat[0][1]= -a[2];
rmat[0][2]= a[1];
rmat[1][0]= a[2];
rmat[1][2]= -a[0];
rmat[2][0]= -a[1];
rmat[2][1]= a[0];
}
/*********************************** Length **********************************/
@ -465,27 +465,27 @@ MINLINE int is_zero_v4(const float v[4])
return (v[0] == 0 && v[1] == 0 && v[2] == 0 && v[3] == 0);
}
MINLINE int is_one_v3(const float *v)
MINLINE int is_one_v3(const float v[3])
{
return (v[0] == 1 && v[1] == 1 && v[2] == 1);
}
MINLINE int equals_v2v2(const float *v1, const float *v2)
MINLINE int equals_v2v2(const float v1[2], const float v2[2])
{
return ((v1[0]==v2[0]) && (v1[1]==v2[1]));
}
MINLINE int equals_v3v3(const float *v1, const float *v2)
MINLINE int equals_v3v3(const float v1[3], const float v2[3])
{
return ((v1[0]==v2[0]) && (v1[1]==v2[1]) && (v1[2]==v2[2]));
}
MINLINE int equals_v4v4(const float *v1, const float *v2)
MINLINE int equals_v4v4(const float v1[4], const float v2[4])
{
return ((v1[0]==v2[0]) && (v1[1]==v2[1]) && (v1[2]==v2[2]) && (v1[3]==v2[3]));
}
MINLINE int compare_v3v3(const float *v1, const float *v2, const float limit)
MINLINE int compare_v3v3(const float v1[3], const float v2[3], const float limit)
{
if(fabsf(v1[0]-v2[0])<limit)
if(fabsf(v1[1]-v2[1])<limit)
@ -495,7 +495,7 @@ MINLINE int compare_v3v3(const float *v1, const float *v2, const float limit)
return 0;
}
MINLINE int compare_len_v3v3(const float *v1, const float *v2, const float limit)
MINLINE int compare_len_v3v3(const float v1[3], const float v2[3], const float limit)
{
float x,y,z;
@ -506,7 +506,7 @@ MINLINE int compare_len_v3v3(const float *v1, const float *v2, const float limit
return ((x*x + y*y + z*z) < (limit*limit));
}
MINLINE int compare_v4v4(const float *v1, const float *v2, const float limit)
MINLINE int compare_v4v4(const float v1[4], const float v2[4], const float limit)
{
if(fabsf(v1[0]-v2[0])<limit)
if(fabsf(v1[1]-v2[1])<limit)
@ -517,7 +517,7 @@ MINLINE int compare_v4v4(const float *v1, const float *v2, const float limit)
return 0;
}
MINLINE float line_point_side_v2(const float *l1, const float *l2, const float *pt)
MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2])
{
return ((l1[0]-pt[0]) * (l2[1]-pt[1])) -
((l2[0]-pt[0]) * (l1[1]-pt[1]));

@ -251,7 +251,7 @@ static float newPerlin(float x, float y, float z)
/* for use with BLI_gNoise()/BLI_gTurbulence(), returns unsigned improved perlin noise */
static float newPerlinU(float x, float y, float z)
{
return (0.5+0.5*newPerlin(x, y, z));
return (0.5f+0.5f*newPerlin(x, y, z));
}
@ -278,12 +278,12 @@ static float orgBlenderNoise(float x, float y, float z)
cn1=ox*ox; cn2=oy*oy; cn3=oz*oz;
cn4=jx*jx; cn5=jy*jy; cn6=jz*jz;
cn1= 1.0-3.0*cn1+2.0*cn1*ox;
cn2= 1.0-3.0*cn2+2.0*cn2*oy;
cn3= 1.0-3.0*cn3+2.0*cn3*oz;
cn4= 1.0-3.0*cn4-2.0*cn4*jx;
cn5= 1.0-3.0*cn5-2.0*cn5*jy;
cn6= 1.0-3.0*cn6-2.0*cn6*jz;
cn1= 1.0f-3.0f*cn1+2.0f*cn1*ox;
cn2= 1.0f-3.0f*cn2+2.0f*cn2*oy;
cn3= 1.0f-3.0f*cn3+2.0f*cn3*oz;
cn4= 1.0f-3.0f*cn4-2.0f*cn4*jx;
cn5= 1.0f-3.0f*cn5-2.0f*cn5*jy;
cn6= 1.0f-3.0f*cn6-2.0f*cn6*jz;
b00= hash[ hash[ix & 255]+(iy & 255)];
b10= hash[ hash[(ix+1) & 255]+(iy & 255)];
@ -325,23 +325,23 @@ static float orgBlenderNoise(float x, float y, float z)
h=hashvectf+ 3*hash[b21+b11];
n+= i*(h[0]*jx+h[1]*jy+h[2]*jz);
if(n<0.0) n=0.0; else if(n>1.0) n=1.0;
if(n<0.0f) n=0.0f; else if(n>1.0f) n=1.0f;
return n;
}
/* as orgBlenderNoise(), returning signed noise */
static float orgBlenderNoiseS(float x, float y, float z)
{
return (2.0*orgBlenderNoise(x, y, z)-1.0);
return (2.0f*orgBlenderNoise(x, y, z)-1.0f);
}
/* separated from orgBlenderNoise above, with scaling */
float BLI_hnoise(float noisesize, float x, float y, float z)
{
if(noisesize==0.0) return 0.0;
x= (1.0+x)/noisesize;
y= (1.0+y)/noisesize;
z= (1.0+z)/noisesize;
if(noisesize==0.0f) return 0.0f;
x= (1.0f+x)/noisesize;
y= (1.0f+y)/noisesize;
z= (1.0f+z)/noisesize;
return orgBlenderNoise(x, y, z);
}
@ -357,7 +357,7 @@ float BLI_turbulence(float noisesize, float x, float y, float z, int nr)
s+= d*BLI_hnoise(noisesize*d, x, y, z);
div+= d;
d*= 0.5;
d*= 0.5f;
nr--;
}
@ -368,13 +368,13 @@ float BLI_turbulence1(float noisesize, float x, float y, float z, int nr)
{
float s, d= 0.5, div=1.0;
s= fabs( (-1.0+2.0*BLI_hnoise(noisesize, x, y, z)));
s= fabsf( (-1.0f+2.0f*BLI_hnoise(noisesize, x, y, z)));
while(nr>0) {
s+= fabs(d* (-1.0+2.0*BLI_hnoise(noisesize*d, x, y, z)));
s+= fabsf(d* (-1.0f+2.0f*BLI_hnoise(noisesize*d, x, y, z)));
div+= d;
d*= 0.5;
d*= 0.5f;
nr--;
}
@ -917,11 +917,11 @@ static float g[512+2][3]= {
#define DOT(a,b) (a[0] * b[0] + a[1] * b[1] + a[2] * b[2])
#define setup(i,b0,b1,r0,r1) \
t = vec[i] + 10000.; \
t = vec[i] + 10000.0f; \
b0 = ((int)t) & 255; \
b1 = (b0+1) & 255; \
r0 = t - (int)t; \
r1 = r0 - 1.;
r0 = t - floorf(t); \
r1 = r0 - 1.0f;
static float noise3_perlin(float vec[3])
@ -945,7 +945,7 @@ static float noise3_perlin(float vec[3])
#define at(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] )
#define surve(t) ( t * t * (3. - 2. * t) )
#define surve(t) ( t * t * (3.0f - 2.0f * t) )
/* lerp moved to improved perlin above */
@ -982,7 +982,7 @@ static float noise3_perlin(float vec[3])
d = lerp(sy, a, b); /* interpolate in y at hi x */
return 1.5 * lerp(sz, c, d); /* interpolate in z */
return 1.5f * lerp(sz, c, d); /* interpolate in z */
}
#if 0
@ -996,7 +996,7 @@ static float turbulence_perlin(float *point, float lofreq, float hifreq)
t = 0;
for (freq = lofreq ; freq < hifreq ; freq *= 2.) {
t += fabs(noise3_perlin(p)) / freq;
t += fabsf(noise3_perlin(p)) / freq;
p[0] *= 2.;
p[1] *= 2.;
p[2] *= 2.;
@ -1024,7 +1024,7 @@ static float orgPerlinNoiseU(float x, float y, float z)
v[0] = x;
v[1] = y;
v[2] = z;
return (0.5+0.5*noise3_perlin(v));
return (0.5f+0.5f*noise3_perlin(v));
}
/* *************** CALL AS: *************** */
@ -1061,18 +1061,18 @@ float BLI_hnoisep(float noisesize, float x, float y, float z)
/* distance squared */
static float dist_Squared(float x, float y, float z, float e) { (void)e; return (x*x + y*y + z*z); }
/* real distance */
static float dist_Real(float x, float y, float z, float e) { (void)e; return sqrt(x*x + y*y + z*z); }
static float dist_Real(float x, float y, float z, float e) { (void)e; return sqrtf(x*x + y*y + z*z); }
/* manhattan/taxicab/cityblock distance */
static float dist_Manhattan(float x, float y, float z, float e) { (void)e; return (fabs(x) + fabs(y) + fabs(z)); }
static float dist_Manhattan(float x, float y, float z, float e) { (void)e; return (fabsf(x) + fabsf(y) + fabsf(z)); }
/* Chebychev */
static float dist_Chebychev(float x, float y, float z, float e)
{
float t;
(void)e;
x = fabs(x);
y = fabs(y);
z = fabs(z);
x = fabsf(x);
y = fabsf(y);
z = fabsf(z);
t = (x>y)?x:y;
return ((z>t)?z:t);
}
@ -1080,7 +1080,7 @@ static float dist_Chebychev(float x, float y, float z, float e)
/* minkovsky preset exponent 0.5 */
static float dist_MinkovskyH(float x, float y, float z, float e)
{
float d = sqrt(fabs(x)) + sqrt(fabs(y)) + sqrt(fabs(z));
float d = sqrtf(fabsf(x)) + sqrtf(fabsf(y)) + sqrtf(fabsf(z));
(void)e;
return (d*d);
}
@ -1092,13 +1092,13 @@ static float dist_Minkovsky4(float x, float y, float z, float e)
x *= x;
y *= y;
z *= z;
return sqrt(sqrt(x*x + y*y + z*z));
return sqrtf(sqrtf(x*x + y*y + z*z));
}
/* Minkovsky, general case, slow, maybe too slow to be useful */
static float dist_Minkovsky(float x, float y, float z, float e)
{
return pow(pow(fabs(x), e) + pow(fabs(y), e) + pow(fabs(z), e), 1.0/e);
return powf(powf(fabsf(x), e) + powf(fabsf(y), e) + powf(fabsf(z), e), 1.0f/e);
}
@ -1224,35 +1224,35 @@ static float voronoi_F1S(float x, float y, float z)
{
float da[4], pa[12];
voronoi(x, y, z, da, pa, 1, 0);
return (2.0*da[0]-1.0);
return (2.0f*da[0]-1.0f);
}
static float voronoi_F2S(float x, float y, float z)
{
float da[4], pa[12];
voronoi(x, y, z, da, pa, 1, 0);
return (2.0*da[1]-1.0);
return (2.0f*da[1]-1.0f);
}
static float voronoi_F3S(float x, float y, float z)
{
float da[4], pa[12];
voronoi(x, y, z, da, pa, 1, 0);
return (2.0*da[2]-1.0);
return (2.0f*da[2]-1.0f);
}
static float voronoi_F4S(float x, float y, float z)
{
float da[4], pa[12];
voronoi(x, y, z, da, pa, 1, 0);
return (2.0*da[3]-1.0);
return (2.0f*da[3]-1.0f);
}
static float voronoi_F1F2S(float x, float y, float z)
{
float da[4], pa[12];
voronoi(x, y, z, da, pa, 1, 0);
return (2.0*(da[1]-da[0])-1.0);
return (2.0f*(da[1]-da[0])-1.0f);
}
/* Crackle type pattern, just a scale/clamp of F2-F1 */
@ -1260,7 +1260,7 @@ static float voronoi_CrS(float x, float y, float z)
{
float t = 10*voronoi_F1F2(x, y, z);
if (t>1.f) return 1.f;
return (2.0*t-1.0);
return (2.0f*t-1.0f);
}
@ -1280,13 +1280,13 @@ static float cellNoiseU(float x, float y, float z)
int zi = (int)(floor(z));
unsigned int n = xi + yi*1301 + zi*314159;
n ^= (n<<13);
return ((float)(n*(n*n*15731 + 789221) + 1376312589) / 4294967296.0);
return ((float)(n*(n*n*15731 + 789221) + 1376312589) / 4294967296.0f);
}
/* idem, signed */
float cellNoise(float x, float y, float z)
{
return (2.0*cellNoiseU(x, y, z)-1.0);
return (2.0f*cellNoiseU(x, y, z)-1.0f);
}
/* returns a vector/point/color in ca, using point hasharray directly */
@ -1349,14 +1349,14 @@ float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noise
}
}
if (noisesize!=0.0) {
noisesize = 1.0/noisesize;
if (noisesize!=0.0f) {
noisesize = 1.0f/noisesize;
x *= noisesize;
y *= noisesize;
z *= noisesize;
}
if (hard) return fabs(2.0*noisefunc(x, y, z)-1.0);
if (hard) return fabsf(2.0f*noisefunc(x, y, z)-1.0f);
return noisefunc(x, y, z);
}
@ -1403,17 +1403,17 @@ float BLI_gTurbulence(float noisesize, float x, float y, float z, int oct, int h
z += 1;
}
if (noisesize!=0.0) {
noisesize = 1.0/noisesize;
if (noisesize!=0.0f) {
noisesize = 1.0f/noisesize;
x *= noisesize;
y *= noisesize;
z *= noisesize;
}
sum = 0;
for (i=0;i<=oct;i++, amp*=0.5, fscale*=2) {
for (i=0;i<=oct;i++, amp*=0.5f, fscale*=2.0f) {
t = noisefunc(fscale*x, fscale*y, fscale*z);
if (hard) t = fabs(2.0*t-1.0);
if (hard) t = fabsf(2.0f*t-1.0f);
sum += t * amp;
}
@ -1439,7 +1439,7 @@ float BLI_gTurbulence(float noisesize, float x, float y, float z, int oct, int h
*/
float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
{
float rmd, value=0.0, pwr=1.0, pwHL=pow(lacunarity, -H);
float rmd, value=0.0, pwr=1.0, pwHL=powf(lacunarity, -H);
int i;
float (*noisefunc)(float, float, float);
@ -1485,7 +1485,7 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
z *= lacunarity;
}
rmd = octaves - floor(octaves);
rmd = octaves - floorf(octaves);
if (rmd!=0.f) value += rmd * noisefunc(x, y, z) * pwr;
return value;
@ -1508,9 +1508,9 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
* I modified it to something that made sense to me, so it might be wrong... */
float mg_MultiFractal(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
{
float rmd, value=1.0, pwr=1.0, pwHL=pow(lacunarity, -H);
float rmd, value=1.0, pwr=1.0, pwHL=powf(lacunarity, -H);
int i;
float (*noisefunc)(float, float, float);
switch (noisebasis) {
case 1:
@ -1547,14 +1547,14 @@ float mg_MultiFractal(float x, float y, float z, float H, float lacunarity, floa
}
for (i=0; i<(int)octaves; i++) {
value *= (pwr * noisefunc(x, y, z) + 1.0);
value *= (pwr * noisefunc(x, y, z) + 1.0f);
pwr *= pwHL;
x *= lacunarity;
y *= lacunarity;
z *= lacunarity;
}
rmd = octaves - floor(octaves);
if (rmd!=0.0) value *= (rmd * noisefunc(x, y, z) * pwr + 1.0);
rmd = octaves - floorf(octaves);
if (rmd!=0.0f) value *= (rmd * noisefunc(x, y, z) * pwr + 1.0f);
return value;
@ -1574,7 +1574,7 @@ float mg_HeteroTerrain(float x, float y, float z, float H, float lacunarity, flo
{
float value, increment, rmd;
int i;
float pwHL = pow(lacunarity, -H);
float pwHL = powf(lacunarity, -H);
float pwr = pwHL; /* starts with i=1 instead of 0 */
float (*noisefunc)(float, float, float);
@ -1627,8 +1627,8 @@ float mg_HeteroTerrain(float x, float y, float z, float H, float lacunarity, flo
z *= lacunarity;
}
rmd = octaves - floor(octaves);
if (rmd!=0.0) {
rmd = octaves - floorf(octaves);
if (rmd!=0.0f) {
increment = (noisefunc(x, y, z) + offset) * pwr * value;
value += rmd * increment;
}
@ -1647,7 +1647,7 @@ float mg_HybridMultiFractal(float x, float y, float z, float H, float lacunarity
{
float result, signal, weight, rmd;
int i;
float pwHL = pow(lacunarity, -H);
float pwHL = powf(lacunarity, -H);
float pwr = pwHL; /* starts with i=1 instead of 0 */
float (*noisefunc)(float, float, float);
@ -1691,8 +1691,8 @@ float mg_HybridMultiFractal(float x, float y, float z, float H, float lacunarity
y *= lacunarity;
z *= lacunarity;
for (i=1; (weight>0.001) && (i<(int)octaves); i++) {
if (weight>1.0) weight=1.0;
for (i=1; (weight>0.001f) && (i<(int)octaves); i++) {
if (weight>1.0f) weight=1.0f;
signal = (noisefunc(x, y, z) + offset) * pwr;
pwr *= pwHL;
result += weight * signal;
@ -1702,7 +1702,7 @@ float mg_HybridMultiFractal(float x, float y, float z, float H, float lacunarity
z *= lacunarity;
}
rmd = octaves - floor(octaves);
rmd = octaves - floorf(octaves);
if (rmd!=0.f) result += rmd * ((noisefunc(x, y, z) + offset) * pwr);
return result;
@ -1722,7 +1722,7 @@ float mg_RidgedMultiFractal(float x, float y, float z, float H, float lacunarity
{
float result, signal, weight;
int i;
float pwHL = pow(lacunarity, -H);
float pwHL = powf(lacunarity, -H);
float pwr = pwHL; /* starts with i=1 instead of 0 */
float (*noisefunc)(float, float, float);
@ -1760,7 +1760,7 @@ float mg_RidgedMultiFractal(float x, float y, float z, float H, float lacunarity
}
}
signal = offset - fabs(noisefunc(x, y, z));
signal = offset - fabsf(noisefunc(x, y, z));
signal *= signal;
result = signal;
@ -1770,8 +1770,8 @@ float mg_RidgedMultiFractal(float x, float y, float z, float H, float lacunarity
y *= lacunarity;
z *= lacunarity;
weight = signal * gain;
if (weight>1.0) weight=1.0; else if (weight<0.0) weight=0.0;
signal = offset - fabs(noisefunc(x, y, z));
if (weight>1.0f) weight=1.0f; else if (weight<0.0f) weight=0.0f;
signal = offset - fabsf(noisefunc(x, y, z));
signal *= signal;
signal *= weight;
result += signal * pwr;
@ -1859,9 +1859,9 @@ float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nba
}
/* get a random vector and scale the randomization */
rv[0] = noisefunc1(x+13.5, y+13.5, z+13.5) * distortion;
rv[0] = noisefunc1(x+13.5f, y+13.5f, z+13.5f) * distortion;
rv[1] = noisefunc1(x, y, z) * distortion;
rv[2] = noisefunc1(x-13.5, y-13.5, z-13.5) * distortion;
rv[2] = noisefunc1(x-13.5f, y-13.5f, z-13.5f) * distortion;
return noisefunc2(x+rv[0], y+rv[1], z+rv[2]); /* distorted-domain noise */
}

@ -117,6 +117,49 @@ char *BLI_sprintfN(const char *format, ...)
return n;
}
/* match pythons string escaping, assume double quotes - (")
* TODO: should be used to create RNA animation paths.
* TODO: support more fancy string escaping. current code is primitive
* this basically is an ascii version of PyUnicode_EncodeUnicodeEscape()
* which is a useful reference. */
size_t BLI_strescape(char *dst, const char *src, const size_t maxlen)
{
size_t len= 0;
while(len < maxlen) {
switch(*src) {
case '\0':
break;
case '\\':
case '"':
/* less common but should also be support */
case '\t':
case '\n':
case '\r':
if(len + 1 < maxlen) {
*dst++ = '\\';
len++;
}
else {
/* not enough space to escape */
break;
}
/* intentionally pass through */
default:
*dst = *src;
}
dst++;
src++;
len++;
}
*dst= '\0';
return len;
}
/* Makes a copy of the text within the "" that appear after some text 'blahblah'
* i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples"
*

@ -115,7 +115,7 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
buf[2]= buf[2]?buf[2]:' ';
buf[3]= buf[3]?buf[3]:' ';
fprintf(fp, "['%.4s', '%s', %d, %ld ], \n", buf, name, bhead->nr, (long int)bhead->len+sizeof(BHead));
fprintf(fp, "['%.4s', '%s', %d, %ld ], \n", buf, name, bhead->nr, (long int)(bhead->len+sizeof(BHead)));
}
}
fprintf(fp, "]\n");

@ -9992,12 +9992,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if(ed) {
SEQP_BEGIN(ed, seq) {
if (seq->strip && seq->strip->proxy){
if (sce->r.size != 100.0) {
seq->strip->proxy->size
= sce->r.size;
} else {
seq->strip->proxy->size = 25;
}
seq->strip->proxy->quality =90;
}
}
@ -10104,7 +10098,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
* to have them show in RNA viewer and accessible otherwise.
*/
for(ma= main->mat.first; ma; ma= ma->id.next) {
if(ma->nodetree && strlen(ma->nodetree->id.name)==0)
if(ma->nodetree && ma->nodetree->id.name[0] == '\0')
strcpy(ma->nodetree->id.name, "NTShader Nodetree");
/* which_output 0 is now "not specified" */
@ -10118,7 +10112,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
/* and composit trees */
for(sce= main->scene.first; sce; sce= sce->id.next) {
if(sce->nodetree && strlen(sce->nodetree->id.name)==0)
if(sce->nodetree && sce->nodetree->id.name[0] == '\0')
strcpy(sce->nodetree->id.name, "NTCompositing Nodetree");
/* move to cameras */
@ -10140,7 +10134,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
bNode *node;
if(tx->nodetree) {
if(strlen(tx->nodetree->id.name)==0)
if(tx->nodetree->id.name[0] == '\0')
strcpy(tx->nodetree->id.name, "NTTexture Nodetree");
/* which_output 0 is now "not specified" */
@ -11749,10 +11743,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
/* put compatibility code here until next subversion bump */
{
if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 1)){
{
Scene *scene;
Sequence *seq;
@ -11868,7 +11860,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
/* put compatibility code here until next subversion bump */
{
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */

@ -868,10 +868,12 @@ static void write_particlesettings(WriteData *wd, ListBase *idbase)
for(; dw; dw=dw->next) {
/* update indices */
dw->index = 0;
go = part->dup_group->gobject.first;
while(go && go->ob != dw->ob) {
go=go->next;
dw->index++;
if(part->dup_group) { /* can be NULL if lining fails or set to None */
go = part->dup_group->gobject.first;
while(go && go->ob != dw->ob) {
go=go->next;
dw->index++;
}
}
writestruct(wd, DATA, "ParticleDupliWeight", 1, dw);
}

@ -39,27 +39,9 @@ set(INC
)
set(INC_SYS
${OPENCOLLADA_INCLUDE_DIRS}
)
if(APPLE)
list(APPEND INC_SYS
${OPENCOLLADA_INCLUDE_DIR}/COLLADAStreamWriter
${OPENCOLLADA_INCLUDE_DIR}/COLLADABaseUtils
${OPENCOLLADA_INCLUDE_DIR}/COLLADAFramework
${OPENCOLLADA_INCLUDE_DIR}/COLLADASaxFrameworkLoader
${OPENCOLLADA_INCLUDE_DIR}/GeneratedSaxParser
)
else()
list(APPEND INC_SYS
${OPENCOLLADA_INCLUDE_DIR}/COLLADAStreamWriter/include
${OPENCOLLADA_INCLUDE_DIR}/COLLADABaseUtils/include
${OPENCOLLADA_INCLUDE_DIR}/COLLADAFramework/include
${OPENCOLLADA_INCLUDE_DIR}/COLLADASaxFrameworkLoader/include
${OPENCOLLADA_INCLUDE_DIR}/GeneratedSaxParser/include
)
endif()
set(SRC
AnimationImporter.cpp
AnimationExporter.cpp

@ -38,6 +38,6 @@ else:
incs = '../blenlib ../blenkernel ../windowmanager ../makesdna ../blenloader ../makesrna ../editors/include ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter/include [OPENCOLLADA]/COLLADABaseUtils/include [OPENCOLLADA]/COLLADAFramework/include [OPENCOLLADA]/COLLADASaxFrameworkLoader/include [OPENCOLLADA]/GeneratedSaxParser/include '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC'])
if env['BF_BUILDINFO']:
defs.append('NAN_BUILDINFO')
defs.append('WITH_BUILDINFO')
env.BlenderLib ('bf_collada', sources, Split(incs), defs, libtype='core', priority=200 )

@ -337,7 +337,7 @@ void debug_markers_print_list(ListBase *markers)
printf("List of markers follows: -----\n");
for (marker = markers->first; marker; marker = marker->next) {
printf("\t'%s' on %d at %p with %d\n", marker->name, marker->frame, (void *)marker, marker->flag);
printf("\t'%s' on %d at %p with %u\n", marker->name, marker->frame, (void *)marker, marker->flag);
}
printf("End of list ------------------\n");

@ -160,7 +160,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
if (i == 1)
strcpy(xval, "x");
else
sprintf(xval, "x^%d", i);
sprintf(xval, "x^%u", i);
uiDefBut(block, LABEL, 1, xval, 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, "Power of x");
}

@ -492,15 +492,32 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
EditBone *ebone;
bArmature *arm= ob->data;
float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */
float mat3[3][3];
copy_m3_m4(mat3, mat);
normalize_m3(mat3);
/* Put the armature into editmode */
ED_armature_to_edit(ob);
/* Do the rotations */
for (ebone = arm->edbo->first; ebone; ebone=ebone->next){
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
float delta[3], tmat[3][3];
/* find the current bone's roll matrix */
sub_v3_v3v3(delta, ebone->tail, ebone->head);
vec_roll_to_mat3(delta, ebone->roll, tmat);
/* transform the roll matrix */
mul_m3_m3m3(tmat, mat3, tmat);
/* transform the bone */
mul_m4_v3(mat, ebone->head);
mul_m4_v3(mat, ebone->tail);
/* apply the transfiormed roll back */
mat3_to_vec_roll(tmat, NULL, &ebone->roll);
ebone->rad_head *= scale;
ebone->rad_tail *= scale;
ebone->dist *= scale;
@ -5403,12 +5420,14 @@ void ED_armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep)
ScrArea *sa;
/* add regions */
for(sa= screen->areabase.first; sa; sa= sa->next) {
SpaceLink *sl= sa->spacedata.first;
if(sl->spacetype == SPACE_VIEW3D) {
View3D *v3d= (View3D *)sl;
if(v3d->ob_centre && v3d->ob_centre->data == arm) {
if (!strcmp(v3d->ob_centre_bone, oldname)) {
BLI_strncpy(v3d->ob_centre_bone, newname, MAXBONENAME);
SpaceLink *sl;
for (sl= sa->spacedata.first; sl; sl= sl->next) {
if(sl->spacetype==SPACE_VIEW3D) {
View3D *v3d= (View3D *)sl;
if(v3d->ob_centre && v3d->ob_centre->data == arm) {
if (!strcmp(v3d->ob_centre_bone, oldname)) {
BLI_strncpy(v3d->ob_centre_bone, newname, MAXBONENAME);
}
}
}
}

@ -288,7 +288,7 @@ unsigned int ED_viewedit_datamask(struct bScreen *screen);
int ED_view3d_camera_lock_check(struct View3D *v3d, struct RegionView3D *rv3d);
/* copy the camera to the view before starting a view transformation */
void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d);
/* copy the view to the camera */
void ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d);
/* copy the view to the camera, return TRUE if */
int ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d);
#endif /* ED_VIEW3D_H */

@ -530,14 +530,11 @@ static void ui_draw_but_CHARTAB(uiBut *but)
int charmax = G.charmax;
/* FO_BUILTIN_NAME font in use. There are TTF FO_BUILTIN_NAME and non-TTF FO_BUILTIN_NAME fonts */
if(!strcmp(G.selfont->name, FO_BUILTIN_NAME))
{
if(G.ui_international == TRUE)
{
if(!strcmp(G.selfont->name, FO_BUILTIN_NAME)) {
if(G.ui_international == TRUE) {
charmax = 0xff;
}
else
{
else {
charmax = 0xff;
}
}
@ -562,16 +559,13 @@ static void ui_draw_but_CHARTAB(uiBut *but)
cs = G.charstart;
/* Set the font, in case it is not FO_BUILTIN_NAME font */
if(G.selfont && strcmp(G.selfont->name, FO_BUILTIN_NAME))
{
if(G.selfont && strcmp(G.selfont->name, FO_BUILTIN_NAME)) {
// Is the font file packed, if so then use the packed file
if(G.selfont->packedfile)
{
if(G.selfont->packedfile) {
pf = G.selfont->packedfile;
FTF_SetFont(pf->data, pf->size, 14.0);
}
else
{
else {
char tmpStr[256];
int err;
@ -580,10 +574,8 @@ static void ui_draw_but_CHARTAB(uiBut *but)
err = FTF_SetFont((unsigned char *)tmpStr, 0, 14.0);
}
}
else
{
if(G.ui_international == TRUE)
{
else {
if(G.ui_international == TRUE) {
FTF_SetFont((unsigned char *) datatoc_bfont_ttf, datatoc_bfont_ttf_size, 14.0);
}
}
@ -595,8 +587,7 @@ static void ui_draw_but_CHARTAB(uiBut *but)
glRectf((rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax));
glColor3ub(0, 0, 0);
for(y = 0; y < 6; y++)
{
for(y = 0; y < 6; y++) {
// Do not draw more than the category allows
if(cs > charmax) break;
@ -676,23 +667,19 @@ static void ui_draw_but_CHARTAB(uiBut *but)
glShadeModel(GL_FLAT);
/* Return Font Settings to original */
if(U.fontsize && U.fontname[0])
{
if(U.fontsize && U.fontname[0]) {
result = FTF_SetFont((unsigned char *)U.fontname, 0, U.fontsize);
}
else if (U.fontsize)
{
else if (U.fontsize) {
result = FTF_SetFont((unsigned char *) datatoc_bfont_ttf, datatoc_bfont_ttf_size, U.fontsize);
}
if (result == 0)
{
if (result == 0) {
result = FTF_SetFont((unsigned char *) datatoc_bfont_ttf, datatoc_bfont_ttf_size, 11);
}
/* resets the font size */
if(G.ui_international == TRUE)
{
if(G.ui_international == TRUE) {
// uiSetCurFont(but->block, UI_HELV);
}
}
@ -1604,7 +1591,6 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, int UNUSED(select))
#endif
{
a= i*aspect;
}
for(; i--; a-=aspect) {

@ -800,8 +800,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
if(!act_iter) return;
/* (3) add a new controller */
if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, NULL) & OPERATOR_FINISHED)
{
if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, NULL) & OPERATOR_FINISHED) {
cont = (bController *)ob->controllers.last;
/* (4) link the sensor->controller->actuator */

@ -1103,8 +1103,7 @@ int ui_id_icon_get(bContext *C, ID *id, int big)
int iconid= 0;
/* icon */
switch(GS(id->name))
{
switch(GS(id->name)) {
case ID_BR:
iconid= ui_id_brush_get_icon(C, id);
break;

@ -1361,7 +1361,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
{
MenuType *mt= (MenuType*)arg_mt;
Menu menu = {0};
Menu menu = {NULL};
menu.type= mt;
menu.layout= layout;

@ -2373,6 +2373,7 @@ void uiTemplateOperatorSearch(uiLayout *layout)
#define B_STOPCAST 2
#define B_STOPANIM 3
#define B_STOPCOMPO 4
#define B_STOPSEQ 5
static void do_running_jobs(bContext *C, void *UNUSED(arg), int event)
{
@ -2389,6 +2390,9 @@ static void do_running_jobs(bContext *C, void *UNUSED(arg), int event)
case B_STOPCOMPO:
WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
break;
case B_STOPSEQ:
WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
break;
}
}
@ -2410,8 +2414,11 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
if(WM_jobs_test(wm, sa))
owner = sa;
handle_event= B_STOPCOMPO;
}
else {
} else if (sa->spacetype==SPACE_SEQ) {
if(WM_jobs_test(wm, sa))
owner = sa;
handle_event = B_STOPSEQ;
} else {
Scene *scene;
/* another scene can be rendering too, for example via compositor */
for(scene= CTX_data_main(C)->scene.first; scene; scene= scene->id.next)

@ -1588,6 +1588,14 @@ void init_userdef_do_versions(void)
}
}
if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
bTheme *btheme;
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
btheme->tv3d.speaker[3] = 255;
}
}
/* GL Texture Garbage Collection (variable abused above!) */
if (U.textimeout == 0) {
U.texcollectrate = 60;
@ -1625,13 +1633,6 @@ void init_userdef_do_versions(void)
NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE;
}
{
bTheme *btheme;
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
btheme->tv3d.speaker[3] = 255;
}
}
/* funny name, but it is GE stuff, moves userdef stuff to engine */
// XXX space_set_commmandline_options();
/* this timer uses U */

@ -1280,7 +1280,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
if(mmd->bindcagecos) {
if(mmd->bindcagecos) MEM_freeN(mmd->bindcagecos);
MEM_freeN(mmd->bindcagecos);
if(mmd->dyngrid) MEM_freeN(mmd->dyngrid);
if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences);
if(mmd->bindinfluences) MEM_freeN(mmd->bindinfluences);

@ -3988,7 +3988,7 @@ static void PTCacheUndo_clear(PTCacheEdit *edit)
{
PTCacheUndo *undo;
if(edit==0) return;
if(edit==NULL) return;
undo= edit->undo.first;
while(undo) {

@ -172,7 +172,6 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Free All Physics Bakes";
ot->name= "Free all physics bakes";
ot->idname= "PTCACHE_OT_free_bake_all";
/* api callbacks */

@ -64,6 +64,7 @@
#include "DNA_brush_types.h"
#include "DNA_screen_types.h"
#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"

@ -85,6 +85,8 @@
#include "UI_interface.h"
#include "RE_pipeline.h"
#include "render_intern.h" // own include
/********************** material slot operators *********************/
@ -661,60 +663,21 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot)
/********************** environment map operators *********************/
static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *str, int imtype)
static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, int imtype)
{
ImBuf *ibuf=NULL;
int dx;
int retval;
int relative= (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path"));
if(env->cube[1]==NULL) {
BKE_report(op->reports, RPT_ERROR, "There is no generated environment map available to save");
return OPERATOR_CANCELLED;
}
dx= env->cube[1]->x;
if (env->type == ENV_CUBE) {
ibuf = IMB_allocImBuf(3*dx, 2*dx, 24, IB_rectfloat);
float layout[12];
if ( RNA_struct_find_property(op->ptr, "layout") )
RNA_float_get_array(op->ptr, "layout",layout);
else
memcpy(layout, default_envmap_layout, sizeof(layout));
IMB_rectcpy(ibuf, env->cube[0], 0, 0, 0, 0, dx, dx);
IMB_rectcpy(ibuf, env->cube[1], dx, 0, 0, 0, dx, dx);
IMB_rectcpy(ibuf, env->cube[2], 2*dx, 0, 0, 0, dx, dx);
IMB_rectcpy(ibuf, env->cube[3], 0, dx, 0, 0, dx, dx);
IMB_rectcpy(ibuf, env->cube[4], dx, dx, 0, 0, dx, dx);
IMB_rectcpy(ibuf, env->cube[5], 2*dx, dx, 0, 0, dx, dx);
}
else if (env->type == ENV_PLANE) {
ibuf = IMB_allocImBuf(dx, dx, 24, IB_rectfloat);
IMB_rectcpy(ibuf, env->cube[1], 0, 0, 0, 0, dx, dx);
if (RE_WriteEnvmapResult(op->reports, scene, env, path, imtype, layout)) {
return OPERATOR_FINISHED;
}
else {
BKE_report(op->reports, RPT_ERROR, "Invalid environment map type");
return OPERATOR_CANCELLED;
}
if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
ibuf->profile = IB_PROFILE_LINEAR_RGB;
/* to save, we first get absolute path */
BLI_path_abs(str, G.main->name);
if (BKE_write_ibuf(ibuf, str, imtype, scene->r.subimtype, scene->r.quality)) {
retval = OPERATOR_FINISHED;
}
else {
BKE_reportf(op->reports, RPT_ERROR, "Error saving environment map to %s.", str);
retval = OPERATOR_CANCELLED;
}
/* in case we were saving with relative paths, change back again */
if(relative)
BLI_path_rel(str, G.main->name);
IMB_freeImBuf(ibuf);
ibuf = NULL;
return retval;
}
static int envmap_save_exec(bContext *C, wmOperator *op)
@ -753,7 +716,6 @@ static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event
return envmap_save_exec(C, op);
//RNA_enum_set(op->ptr, "file_type", scene->r.imtype);
RNA_string_set(op->ptr, "filepath", G.main->name);
WM_event_add_fileselect(C, op);
@ -776,6 +738,7 @@ static int envmap_save_poll(bContext *C)
void TEXTURE_OT_envmap_save(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name= "Save Environment Map";
ot->idname= "TEXTURE_OT_envmap_save";
@ -790,8 +753,10 @@ void TEXTURE_OT_envmap_save(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER; /* no undo since this doesnt modify the env-map */
/* properties */
//RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as.");
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
prop= RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face. Order is [+Z -Z +Y -X -Y +X]. Use -1 to skip a face.", 0.0f, 0.0f);
RNA_def_property_flag(prop, PROP_HIDDEN);
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH);
}
static int envmap_clear_exec(bContext *C, wmOperator *UNUSED(op))

@ -533,8 +533,7 @@ int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2)
dir = area_getorientation(sa1, sa2);
/*printf("dir is : %i \n", dir);*/
if (dir < 0)
{
if (dir < 0) {
if (sa1 ) sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
if (sa2 ) sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
return 0;

@ -1544,8 +1544,7 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
/* subtractwidth of regions on opposite side
* prevents dragging regions into other opposite regions */
for (ar=sa->regionbase.first; ar; ar=ar->next)
{
for (ar=sa->regionbase.first; ar; ar=ar->next) {
if (ar == scalear)
continue;
@ -1703,7 +1702,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
int region_scale_cancel(bContext *UNUSED(C), wmOperator *op)
static int region_scale_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
@ -2021,12 +2020,12 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
*/
typedef struct sAreaJoinData
{
ScrArea *sa1; /* first area to be considered */
ScrArea *sa2; /* second area to be considered */
ScrArea *scr; /* designed for removal */
} sAreaJoinData;
{
ScrArea *sa1; /* first area to be considered */
ScrArea *sa2; /* second area to be considered */
ScrArea *scr; /* designed for removal */
} sAreaJoinData;
/* validate selection inside screen, set variables OK */

@ -512,7 +512,7 @@ static float VecZDepthOrtho(float pt[2], float v1[3], float v2[3], float v3[3],
return (v1[2]*w[0]) + (v2[2]*w[1]) + (v3[2]*w[2]);
}
static float VecZDepthPersp(float pt[2], float v1[3], float v2[3], float v3[3], float w[3])
static float VecZDepthPersp(float pt[2], float v1[4], float v2[4], float v3[4], float w[3])
{
float wtot_inv, wtot;
float w_tmp[3];
@ -1193,7 +1193,7 @@ static void screen_px_from_ortho(
* the perspective W coord for each vert */
static void screen_px_from_persp(
float uv[2],
float v1co[3], float v2co[3], float v3co[3], /* screenspace coords */
float v1co[4], float v2co[4], float v3co[4], /* screenspace coords */
float uv1co[2], float uv2co[2], float uv3co[2],
float pixelScreenCo[4],
float w[3])

@ -2979,7 +2979,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
SCULPT_TOOL_GRAB, SCULPT_TOOL_NUDGE,
SCULPT_TOOL_CLAY_TUBES, SCULPT_TOOL_SNAKE_HOOK,
SCULPT_TOOL_THUMB)) {
float grab_location[3], imat[4][4], delta[3];
float grab_location[3], imat[4][4], delta[3], loc[3];
if(cache->first_time) {
copy_v3_v3(cache->orig_grab_location,
@ -2989,10 +2989,8 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
add_v3_v3(cache->true_location, cache->grab_delta);
/* compute 3d coordinate at same z from original location + mouse */
initgrabz(cache->vc->rv3d,
cache->orig_grab_location[0],
cache->orig_grab_location[1],
cache->orig_grab_location[2]);
mul_v3_m4v3(loc, ob->obmat, cache->orig_grab_location);
initgrabz(cache->vc->rv3d, loc[0], loc[1], loc[2]);
ED_view3d_win_to_delta(cache->vc->ar, cache->mouse, grab_location);
@ -3088,9 +3086,6 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st
else {
cache->initial_radius= brush_unprojected_radius(brush);
}
if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK))
cache->initial_radius *= 2.0f;
}
if(brush_use_size_pressure(brush)) {

@ -269,6 +269,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
buttons_area_redraw(sa, BCONTEXT_DATA); /* autotexpace flag */
break;
case ND_POSE:
buttons_area_redraw(sa, BCONTEXT_DATA);
case ND_BONE_ACTIVE:
case ND_BONE_SELECT:
buttons_area_redraw(sa, BCONTEXT_BONE);

@ -165,8 +165,11 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop)
{
char text[64];
ID *id= drag->poin;
char id_esc[(sizeof(id->name) - 2) * 2];
snprintf(text, sizeof(text), "bpy.data.%s['%s']", BKE_idcode_to_name_plural(GS(id->name)), id->name+2);
BLI_strescape(id_esc, id->name+2, sizeof(id_esc));
snprintf(text, sizeof(text), "bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id_esc);
/* copy drag path to properties */
RNA_string_set(drop->ptr, "text", text);

@ -621,25 +621,31 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
}
/* some ops have multiple files to select */
/* this is called on operators check() so clear collections first since
* they may be already set. */
{
PointerRNA itemptr;
PropertyRNA *prop_files= RNA_struct_find_property(op->ptr, "files");
PropertyRNA *prop_dirs= RNA_struct_find_property(op->ptr, "dirs");
int i, numfiles = filelist_numfiles(sfile->files);
if(RNA_struct_find_property(op->ptr, "files")) {
if(prop_files) {
RNA_property_collection_clear(op->ptr, prop_files);
for (i=0; i<numfiles; i++) {
if (filelist_is_selected(sfile->files, i, CHECK_FILES)) {
struct direntry *file= filelist_file(sfile->files, i);
RNA_collection_add(op->ptr, "files", &itemptr);
RNA_property_collection_add(op->ptr, prop_files, &itemptr);
RNA_string_set(&itemptr, "name", file->relname);
}
}
}
if(RNA_struct_find_property(op->ptr, "dirs")) {
if(prop_dirs) {
RNA_property_collection_clear(op->ptr, prop_dirs);
for (i=0; i<numfiles; i++) {
if (filelist_is_selected(sfile->files, i, CHECK_DIRS)) {
struct direntry *file= filelist_file(sfile->files, i);
RNA_collection_add(op->ptr, "dirs", &itemptr);
RNA_property_collection_add(op->ptr, prop_dirs, &itemptr);
RNA_string_set(&itemptr, "name", file->relname);
}
}
@ -651,25 +657,27 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op)
{
int change= FALSE;
if(RNA_struct_find_property(op->ptr, "filename")) {
RNA_string_get(op->ptr, "filename", sfile->params->file);
change= TRUE;
}
if(RNA_struct_find_property(op->ptr, "directory")) {
RNA_string_get(op->ptr, "directory", sfile->params->dir);
change= TRUE;
}
PropertyRNA *prop;
/* If neither of the above are set, split the filepath back */
if(RNA_struct_find_property(op->ptr, "filepath")) {
if(change==FALSE) {
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file);
if((prop= RNA_struct_find_property(op->ptr, "filepath"))) {
char filepath[FILE_MAX];
RNA_property_string_get(op->ptr, prop, filepath);
BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file);
}
else {
if((prop= RNA_struct_find_property(op->ptr, "filename"))) {
RNA_property_string_get(op->ptr, prop, sfile->params->file);
}
if((prop= RNA_struct_find_property(op->ptr, "directory"))) {
RNA_property_string_get(op->ptr, prop, sfile->params->dir);
}
}
/* we could check for relative_path property which is used when converting
* in the other direction but doesnt hurt to do this every time */
BLI_path_abs(sfile->params->dir, G.main->name);
/* XXX, files and dirs updates missing, not really so important though */
}

@ -300,7 +300,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu)
tmp= GetLogicalDrives();
for (i=2; i < 26; i++) {
for (i=0; i < 26; i++) {
if ((tmp>>i) & 1) {
tmps[0]='A'+i;
tmps[1]=':';

@ -113,7 +113,7 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf,
if(ima->source==IMA_SRC_MOVIE) {
ofs+= sprintf(str, "Movie");
if(ima->anim)
ofs+= sprintf(str+ofs, "%d frs", IMB_anim_get_duration(ima->anim));
ofs+= sprintf(str+ofs, "%d frs", IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN));
}
else
ofs+= sprintf(str, "Image");
@ -428,7 +428,7 @@ static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v)
ImageUser *iuser= iuser_v;
if(ima->anim) {
iuser->frames = IMB_anim_get_duration(ima->anim);
iuser->frames = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN);
BKE_image_user_calc_frame(iuser, scene->r.cfra, 0);
}
}

@ -938,9 +938,100 @@ void IMAGE_OT_replace(wmOperatorType *ot)
/******************** save image as operator ********************/
typedef struct {
/* matching scene->r settings */
short planes, imtype, subimtype, quality;
char filepath[FILE_MAX]; /* keep absolute */
} SaveImageOptions;
static void save_image_options_defaults(SaveImageOptions *simopts)
{
simopts->planes= R_PLANES24;
simopts->imtype= R_PNG;
simopts->subimtype= 0;
simopts->quality= 90;
simopts->filepath[0]= '\0';
}
static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, Scene *scene, const short guess_path)
{
void *lock;
ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
if(ibuf) {
Image *ima= sima->image;
RenderResult *rr= BKE_image_acquire_renderresult(scene, ima);
simopts->planes= ibuf->depth;
/* cant save multilayer sequence, ima->rr isn't valid for a specific frame */
if(rr && !(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER))
simopts->imtype= R_MULTILAYER;
else if(ima->type==IMA_TYPE_R_RESULT)
simopts->imtype= scene->r.imtype;
else if (ima->source == IMA_SRC_GENERATED)
simopts->imtype= R_PNG;
else
simopts->imtype= BKE_ftype_to_imtype(ibuf->ftype);
simopts->subimtype= scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */
simopts->quality= ibuf->ftype & 0xff;
BLI_strncpy(simopts->filepath, ibuf->name, sizeof(simopts->filepath));
/* sanitize all settings */
/* unlikely but just incase */
if (ELEM3(simopts->planes, R_PLANESBW, R_PLANES24, R_PLANES32) == 0) {
simopts->planes= R_PLANES32;
}
/* some formats dont use quality so fallback to scenes quality */
if (simopts->quality == 0) {
simopts->quality= scene->r.quality;
}
/* check for empty path */
if(guess_path && simopts->filepath[0]==0) {
if ( (G.ima[0] == '/') && (G.ima[1] == '/') && (G.ima[2] == '\0') ) {
BLI_strncpy(simopts->filepath, "//untitled", FILE_MAX);
} else {
BLI_strncpy(simopts->filepath, G.ima, FILE_MAX);
}
BLI_path_abs(simopts->filepath, G.main->name);
}
/* cleanup */
BKE_image_release_renderresult(scene, ima);
}
ED_space_image_release_buffer(sima, lock);
return (ibuf != NULL);
}
static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op)
{
if (RNA_property_is_set(op->ptr, "color_mode")) simopts->planes= RNA_enum_get(op->ptr, "color_mode");
if (RNA_property_is_set(op->ptr, "file_format")) simopts->imtype= RNA_enum_get(op->ptr, "file_format");
// if (RNA_property_is_set(op->ptr, "subimtype")) simopts->subimtype= RNA_enum_get(op->ptr, "subimtype"); // XXX
if (RNA_property_is_set(op->ptr, "file_quality")) simopts->quality= RNA_int_get(op->ptr, "file_quality");
if (RNA_property_is_set(op->ptr, "filepath")) RNA_string_get(op->ptr, "filepath", simopts->filepath);
}
static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op)
{
RNA_enum_set(op->ptr, "color_mode", simopts->planes);
RNA_enum_set(op->ptr, "file_format", simopts->imtype);
// RNA_enum_set(op->ptr, "subimtype", simopts->subimtype);
RNA_int_set(op->ptr, "file_quality", simopts->quality);
RNA_string_set(op->ptr, "filepath", simopts->filepath);
}
/* assumes name is FILE_MAX */
/* ima->name and ibuf->name should end up the same */
static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOperator *op, char *path, int do_newpath)
static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, int do_newpath)
{
Image *ima= ED_space_image(sima);
void *lock;
@ -952,18 +1043,17 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera
const short save_copy= (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
short ok= FALSE;
BLI_path_abs(path, bmain->name);
/* old global to ensure a 2nd save goes to same dir */
BLI_strncpy(G.ima, path, sizeof(G.ima));
BLI_strncpy(G.ima, simopts->filepath, sizeof(G.ima));
WM_cursor_wait(1);
if(ima->type == IMA_TYPE_R_RESULT) {
/* enforce user setting for RGB or RGBA, but skip BW */
if(scene->r.planes==32) {
if(simopts->planes==R_PLANES32) {
ibuf->depth= 32;
}
else if(scene->r.planes==24) {
else if(simopts->planes==R_PLANES24) {
ibuf->depth= 24;
}
}
@ -974,15 +1064,12 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera
ibuf->depth= BKE_alphatest_ibuf(ibuf) ? 32 : 24;
}
}
if(scene->r.scemode & R_EXTENSION) {
BKE_add_image_extension(path, sima->imtypenr);
}
if(sima->imtypenr==R_MULTILAYER) {
if(simopts->imtype==R_MULTILAYER) {
Scene *scene= CTX_data_scene(C);
RenderResult *rr= BKE_image_acquire_renderresult(scene, ima);
if(rr) {
RE_WriteRenderResult(rr, path, scene->r.quality);
RE_WriteRenderResult(rr, simopts->filepath, simopts->quality);
ok= TRUE;
}
else {
@ -990,23 +1077,23 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera
}
BKE_image_release_renderresult(scene, ima);
}
else if (BKE_write_ibuf(ibuf, path, sima->imtypenr, scene->r.subimtype, scene->r.quality)) {
else if (BKE_write_ibuf(ibuf, simopts->filepath, simopts->imtype, simopts->subimtype, simopts->quality)) {
ok= TRUE;
}
if(ok) {
if(relative)
BLI_path_rel(path, bmain->name); /* only after saving */
BLI_path_rel(simopts->filepath, bmain->name); /* only after saving */
if(ibuf->name[0]==0) {
BLI_strncpy(ibuf->name, path, sizeof(ibuf->name));
BLI_strncpy(ima->name, path, sizeof(ima->name));
BLI_strncpy(ibuf->name, simopts->filepath, sizeof(ibuf->name));
BLI_strncpy(ima->name, simopts->filepath, sizeof(ima->name));
}
if(!save_copy) {
if(do_newpath) {
BLI_strncpy(ima->name, path, sizeof(ima->name));
BLI_strncpy(ibuf->name, path, sizeof(ibuf->name));
BLI_strncpy(ima->name, simopts->filepath, sizeof(ima->name));
BLI_strncpy(ibuf->name, simopts->filepath, sizeof(ibuf->name));
}
ibuf->userflags &= ~IB_BITMAPDIRTY;
@ -1034,7 +1121,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera
}
}
else {
BKE_reportf(op->reports, RPT_ERROR, "Couldn't write image: %s", path);
BKE_reportf(op->reports, RPT_ERROR, "Couldn't write image: %s", simopts->filepath);
}
@ -1049,17 +1136,14 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera
static int save_as_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
Scene *scene= CTX_data_scene(C);
Image *ima = ED_space_image(sima);
char str[FILE_MAX];
SaveImageOptions simopts;
if(!ima)
return OPERATOR_CANCELLED;
/* just incase to initialize values,
* these should be set on invoke or by the caller. */
save_image_options_defaults(&simopts);
save_image_options_from_op(&simopts, op);
sima->imtypenr= RNA_enum_get(op->ptr, "file_type");
RNA_string_get(op->ptr, "filepath", str);
save_image_doit(C, sima, scene, op, str, TRUE);
save_image_doit(C, sima, op, &simopts, TRUE);
return OPERATOR_FINISHED;
}
@ -1069,7 +1153,7 @@ static int save_as_check(bContext *UNUSED(C), wmOperator *op)
{
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
if(BKE_add_image_extension(filepath, RNA_enum_get(op->ptr, "file_type"))) {
if(BKE_add_image_extension(filepath, RNA_enum_get(op->ptr, "file_format"))) {
RNA_string_set(op->ptr, "filepath", filepath);
return TRUE;
}
@ -1081,65 +1165,33 @@ static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
SpaceImage *sima= CTX_wm_space_image(C);
Image *ima = ED_space_image(sima);
Scene *scene= CTX_data_scene(C);
ImBuf *ibuf;
char filename[FILE_MAX];
void *lock;
SaveImageOptions simopts;
if(!RNA_property_is_set(op->ptr, "relative_path"))
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
if(RNA_property_is_set(op->ptr, "filepath"))
return save_as_exec(C, op);
if(!ima)
if (save_image_options_init(&simopts, sima, scene, TRUE) == 0)
return OPERATOR_CANCELLED;
save_image_options_to_op(&simopts, op);
/* always opens fileselect */
ibuf= ED_space_image_acquire_buffer(sima, &lock);
if(ibuf) {
/* cant save multilayer sequence, ima->rr isn't valid for a specific frame */
if(ima->rr && !(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER))
sima->imtypenr= R_MULTILAYER;
else if(ima->type==IMA_TYPE_R_RESULT)
sima->imtypenr= scene->r.imtype;
else if (ima->source == IMA_SRC_GENERATED)
sima->imtypenr= R_PNG;
else
sima->imtypenr= BKE_ftype_to_imtype(ibuf->ftype);
RNA_enum_set(op->ptr, "file_type", sima->imtypenr);
if(ibuf->name[0]==0)
if ( (G.ima[0] == '/') && (G.ima[1] == '/') && (G.ima[2] == '\0') ) {
BLI_strncpy(filename, "//untitled", FILE_MAX);
} else {
BLI_strncpy(filename, G.ima, FILE_MAX);
}
else
BLI_strncpy(filename, ibuf->name, FILE_MAX);
/* enable save_copy by default for render results */
if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE) && !RNA_property_is_set(op->ptr, "copy")) {
RNA_boolean_set(op->ptr, "copy", TRUE);
}
// XXX note: we can give default menu enums to operator for this
image_filesel(C, op, filename);
ED_space_image_release_buffer(sima, lock);
return OPERATOR_RUNNING_MODAL;
/* enable save_copy by default for render results */
if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE) && !RNA_property_is_set(op->ptr, "copy")) {
RNA_boolean_set(op->ptr, "copy", TRUE);
}
ED_space_image_release_buffer(sima, lock);
// XXX note: we can give default menu enums to operator for this
image_filesel(C, op, simopts.filepath);
return OPERATOR_CANCELLED;
return OPERATOR_RUNNING_MODAL;
}
void IMAGE_OT_save_as(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name= "Save As Image";
ot->idname= "IMAGE_OT_save_as";
@ -1154,7 +1206,13 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as.");
/* format options */
RNA_def_enum(ot->srna, "file_format", image_file_type_items, R_PNG, "File Type", "File type to save image as.");
RNA_def_enum(ot->srna, "color_mode", image_color_mode_items, R_PLANES24, "Channels", "Image channels to save");
prop= RNA_def_int(ot->srna, "file_quality", 90, 0, 100, "Quality", "", 0, 100);
RNA_def_property_subtype(prop, PROP_PERCENTAGE);
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
RNA_def_boolean(ot->srna, "copy", 0, "Copy", "Create a new image file without modifying the current image in blender");
@ -1164,45 +1222,19 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
static int save_exec(bContext *C, wmOperator *op)
{
Main *bmain= CTX_data_main(C);
SpaceImage *sima= CTX_wm_space_image(C);
Image *ima = ED_space_image(sima);
void *lock;
ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
Scene *scene= CTX_data_scene(C);
RenderResult *rr;
char name[FILE_MAX];
SaveImageOptions simopts;
if(!ima || !ibuf) {
ED_space_image_release_buffer(sima, lock);
if (save_image_options_init(&simopts, sima, scene, FALSE) == 0)
return OPERATOR_CANCELLED;
}
save_image_options_from_op(&simopts, op);
/* if exists, saves over without fileselect */
BLI_strncpy(name, ima->name, FILE_MAX);
if(name[0]==0)
BLI_strncpy(name, G.ima, FILE_MAX);
else
BLI_path_abs(name, bmain->name);
if(BLI_exists(name) && BLI_is_writable(name)) {
rr= BKE_image_acquire_renderresult(scene, ima);
if(rr)
sima->imtypenr= R_MULTILAYER;
else
sima->imtypenr= BKE_ftype_to_imtype(ibuf->ftype);
BKE_image_release_renderresult(scene, ima);
ED_space_image_release_buffer(sima, lock);
save_image_doit(C, sima, scene, op, name, FALSE);
if (BLI_exists(simopts.filepath) && BLI_is_writable(simopts.filepath)) {
save_image_doit(C, sima, op, &simopts, FALSE);
}
else {
ED_space_image_release_buffer(sima, lock);
BKE_report(op->reports, RPT_ERROR, "Can not save image.");
BKE_reportf(op->reports, RPT_ERROR, "Can not save image, path '%s' is not writable.", simopts.filepath);
return OPERATOR_CANCELLED;
}

@ -3080,78 +3080,115 @@ void NODE_OT_delete(wmOperatorType *ot)
}
/* ****************** Delete with reconnect ******************* */
static int is_connected_to_input_socket(bNode* node, bNodeLink* link) {
bNodeSocket *sock;
if (link->tonode == node) {
for(sock= node->inputs.first; sock; sock= sock->next) {
if (link->tosock == sock) {
return sock->type;
}
}
}
return -1;
}
/* note: in cmp_util.c is similar code, for node_compo_pass_on() */
/* used for disabling node (similar code in node_draw.c for disable line) */
static void node_delete_reconnect(bNodeTree* tree, bNode* node)
{
bNodeLink *link, *next;
bNodeLink *link, *next, *first = NULL;
bNodeSocket *valsocket= NULL, *colsocket= NULL, *vecsocket= NULL;
bNodeSocket *deliveringvalsocket= NULL, *deliveringcolsocket= NULL, *deliveringvecsocket= NULL;
bNode *deliveringvalnode= NULL, *deliveringcolnode= NULL, *deliveringvecnode= NULL;
bNodeSocket *sock;
int type;
int numberOfConnectedOutputSockets = 0;
int numberOfReconnections = 0;
int numberOfConnectedInputSockets = 0;
/* test the inputs */
for(sock= node->inputs.first; sock; sock= sock->next) {
int type = sock->type;
if(type==SOCK_VALUE && valsocket==NULL) valsocket = sock;
if(type==SOCK_VECTOR && vecsocket==NULL) vecsocket = sock;
if(type==SOCK_RGBA && colsocket==NULL) colsocket = sock;
}
// we now have the input sockets for the 'data types'
// now find the output sockets (and nodes) in the tree that delivers data to these input sockets
/*
test the inputs, not really correct when a node has multiple input sockets of the same type
the first link evaluated will be used to determine the possible connection.
*/
for(link= tree->links.first; link; link=link->next) {
if (valsocket != NULL) {
if (link->tosock == valsocket) {
deliveringvalnode = link->fromnode;
deliveringvalsocket = link->fromsock;
}
}
if (vecsocket != NULL) {
if (link->tosock == vecsocket) {
deliveringvecnode = link->fromnode;
deliveringvecsocket = link->fromsock;
}
}
if (colsocket != NULL) {
if (link->tosock == colsocket) {
if (link->tonode == node) { numberOfConnectedInputSockets++; }
type = is_connected_to_input_socket(node, link);
switch (type) {
case SOCK_RGBA:
if (colsocket == NULL) {
colsocket = link->tosock;
deliveringcolnode = link->fromnode;
deliveringcolsocket = link->fromsock;
}
break;
case SOCK_VECTOR:
if (vecsocket == NULL) {
vecsocket = link->tosock;
deliveringvecnode = link->fromnode;
deliveringvecsocket = link->fromsock;
}
break;
case SOCK_VALUE:
if (valsocket == NULL) {
valsocket = link->tosock;
deliveringvalnode = link->fromnode;
deliveringvalsocket = link->fromsock;
}
break;
default:
break;
}
}
// we now have the sockets+nodes that fill the inputsockets be aware for group nodes these can be NULL
// now make the links for all outputlinks of the node to be reconnected
for(link= tree->links.first; link; link=next) {
next= link->next;
if (link->fromnode == node) {
sock = link->fromsock;
numberOfConnectedOutputSockets ++;
if (!first) first = link;
switch(sock->type) {
case SOCK_VALUE:
if (deliveringvalsocket) {
link->fromnode = deliveringvalnode;
link->fromsock = deliveringvalsocket;
numberOfReconnections++;
}
break;
case SOCK_VECTOR:
if (deliveringvecsocket) {
link->fromnode = deliveringvecnode;
link->fromsock = deliveringvecsocket;
numberOfReconnections++;
}
break;
case SOCK_RGBA:
if (deliveringcolsocket) {
link->fromnode = deliveringcolnode;
link->fromsock = deliveringcolsocket;
numberOfReconnections++;
}
break;
}
}
}
/* when no connections have been made, and if only one delivering input socket type and one output socket we will connect those two */
if (numberOfConnectedOutputSockets == 1 && numberOfReconnections == 0 && numberOfConnectedInputSockets == 1) {
if (deliveringcolsocket) {
first->fromnode = deliveringcolnode;
first->fromsock = deliveringcolsocket;
} else if (deliveringvecsocket) {
first->fromnode = deliveringvecnode;
first->fromsock = deliveringvecsocket;
} else if (deliveringvalsocket) {
first->fromnode = deliveringvalnode;
first->fromsock = deliveringvalsocket;
}
}
if(node->id)
node->id->us--;
nodeFreeNode(tree, node);
}
static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op))

@ -83,8 +83,8 @@ void outliner_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "OUTLINER_OT_item_rename", LEFTMOUSE, KM_DBL_CLICK, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_RELEASE, 0, 0)->ptr, "extend", 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_CLICK, 0, 0)->ptr, "extend", 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_CLICK, KM_SHIFT, 0)->ptr, "extend", 1);
RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, 0, 0)->ptr, "all", 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "all", 1);

@ -223,7 +223,7 @@ void outliner_free_tree(ListBase *lb)
}
/* Find ith item from the treestore */
TreeElement *outliner_find_tree_element(ListBase *lb, int store_index)
static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index)
{
TreeElement *te= lb->first, *tes;
while(te) {

@ -8,4 +8,7 @@ incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
incs += ' ../../makesrna ../../blenloader'
incs += ' #/intern/audaspace/intern'
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
incs += ' ' + env['BF_PTHREADS_INC']
env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), [], libtype=['core'], priority=[100] )

@ -733,7 +733,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline
}
}
static Sequence *special_seq_update= 0;
static Sequence *special_seq_update= NULL;
static void UNUSED_FUNCTION(set_special_seq_update)(int val)
{
@ -743,14 +743,14 @@ static void UNUSED_FUNCTION(set_special_seq_update)(int val)
if(val) {
// XXX special_seq_update= find_nearest_seq(&x);
}
else special_seq_update= 0;
else special_seq_update= NULL;
}
void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs)
{
struct Main *bmain= CTX_data_main(C);
struct ImBuf *ibuf = 0;
struct ImBuf *scope = 0;
struct ImBuf *ibuf= NULL;
struct ImBuf *scope= NULL;
struct View2D *v2d = &ar->v2d;
int rectx, recty;
float viewrectx, viewrecty;

@ -47,6 +47,7 @@
#include "BLI_math.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "BLI_threads.h"
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
@ -125,6 +126,111 @@ typedef struct TransSeq {
int len;
} TransSeq;
/* ********************************************************************** */
/* ***************** proxy job manager ********************** */
typedef struct ProxyBuildJob {
Scene *scene;
struct Main * main;
ListBase queue;
ThreadMutex queue_lock;
} ProxyJob;
static void proxy_freejob(void *pjv)
{
ProxyJob *pj= pjv;
Sequence * seq;
for (seq = pj->queue.first; seq; seq = seq->next) {
BLI_remlink(&pj->queue, seq);
seq_free_sequence_recurse(pj->scene, seq);
}
BLI_mutex_end(&pj->queue_lock);
MEM_freeN(pj);
}
/* only this runs inside thread */
static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress)
{
ProxyJob *pj = pjv;
while (!*stop) {
Sequence * seq;
BLI_mutex_lock(&pj->queue_lock);
if (!pj->queue.first) {
BLI_mutex_unlock(&pj->queue_lock);
break;
}
seq = pj->queue.first;
BLI_remlink(&pj->queue, seq);
BLI_mutex_unlock(&pj->queue_lock);
seq_proxy_rebuild(pj->main, pj->scene, seq,
stop, do_update, progress);
seq_free_sequence_recurse(pj->scene, seq);
}
if (*stop) {
fprintf(stderr,
"Canceling proxy rebuild on users request...\n");
}
}
static void proxy_endjob(void *UNUSED(customdata))
{
}
void seq_proxy_build_job(const bContext *C, Sequence * seq)
{
wmJob * steve;
ProxyJob *pj;
Scene *scene= CTX_data_scene(C);
ScrArea * sa= CTX_wm_area(C);
seq = seq_dupli_recursive(scene, scene, seq, 0);
steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C),
sa, "Building Proxies", WM_JOB_PROGRESS);
pj = WM_jobs_get_customdata(steve);
if (!pj) {
pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job");
pj->scene= scene;
pj->main = CTX_data_main(C);
BLI_mutex_init(&pj->queue_lock);
WM_jobs_customdata(steve, pj, proxy_freejob);
WM_jobs_timer(steve, 0.1, NC_SCENE|ND_SEQUENCER,
NC_SCENE|ND_SEQUENCER);
WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL,
proxy_endjob);
}
BLI_mutex_lock(&pj->queue_lock);
BLI_addtail(&pj->queue, seq);
BLI_mutex_unlock(&pj->queue_lock);
if (!WM_jobs_is_running(steve)) {
G.afbreek = 0;
WM_jobs_start(CTX_wm_manager(C), steve);
}
ED_area_tag_redraw(CTX_wm_area(C));
}
/* ********************************************************************** */
void seq_rectf(Sequence *seq, rctf *rectf)
{
if(seq->startstill) rectf->xmin= seq->start;
@ -2690,6 +2796,37 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot)
WM_operator_properties_gesture_border(ot, FALSE);
}
/* rebuild_proxy operator */
static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Editing *ed = seq_give_editing(scene, FALSE);
Sequence * seq;
SEQP_BEGIN(ed, seq) {
if ((seq->flag & SELECT)) {
seq_proxy_build_job(C, seq);
}
}
SEQ_END
return OPERATOR_FINISHED;
}
void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Rebuild Proxy and Timecode Indices";
ot->idname= "SEQUENCER_OT_rebuild_proxy";
ot->description="Rebuild all selected proxies and timecode indeces using the job system";
/* api callbacks */
ot->exec= sequencer_rebuild_proxy_exec;
ot->poll= ED_operator_sequencer_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
}
/* change ops */

@ -118,6 +118,8 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot);
void SEQUENCER_OT_copy(struct wmOperatorType *ot);
void SEQUENCER_OT_paste(struct wmOperatorType *ot);
void SEQUENCER_OT_rebuild_proxy(struct wmOperatorType *ot);
/* preview specific operators */
void SEQUENCER_OT_view_all_preview(struct wmOperatorType *ot);

@ -87,6 +87,7 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_view_zoom_ratio);
WM_operatortype_append(SEQUENCER_OT_view_ghost_border);
WM_operatortype_append(SEQUENCER_OT_rebuild_proxy);
WM_operatortype_append(SEQUENCER_OT_change_effect_input);
WM_operatortype_append(SEQUENCER_OT_change_effect_type);
WM_operatortype_append(SEQUENCER_OT_change_path);

@ -846,7 +846,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op)
for(seq= ed->seqbasep->first; seq; seq= seq->next) {
seq_rectf(seq, &rq);
if(BLI_isect_rctf(&rq, &rectf, 0)) {
if(BLI_isect_rctf(&rq, &rectf, NULL)) {
if(selecting) seq->flag |= SELECT;
else seq->flag &= ~SEQ_ALLSEL;
recurs_sel_seq(seq);

@ -274,7 +274,7 @@ static void text_keymap(struct wmKeyConfig *keyconf)
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", 1);
WM_keymap_add_item(keymap, "TEXT_OT_new", NKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "TEXT_OT_new", NKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "TEXT_OT_open", OKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "TEXT_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "TEXT_OT_save", SKEY, KM_PRESS, KM_ALT, 0);

@ -192,11 +192,12 @@ static int new_exec(bContext *C, wmOperator *UNUSED(op))
void TEXT_OT_new(wmOperatorType *ot)
{
/* identifiers */
ot->name= "New";
ot->name= "Create Text Block";
ot->idname= "TEXT_OT_new";
ot->description= "Create a new text data block";
/* api callbacks */
ot->invoke= WM_operator_confirm;
ot->exec= new_exec;
ot->poll= text_new_poll;

Some files were not shown because too many files have changed in this diff Show More