diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-01-23 02:38:28 +0300 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-01-23 02:38:28 +0300 |
commit | 50ced6b0176db8cf4d2393005be7f371ab9716de (patch) | |
tree | 0788a93e86b4b28c9338c74826aaab93547dbccb | |
parent | c7a122aa27662a2fb528663ddd3dd652cdda2010 (diff) | |
parent | f39c794c7c3eca9c73ea0bdab084e6c191343965 (diff) |
Merged changes in the trunk up to revision 34459.
171 files changed, 1873 insertions, 1092 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a17eaf3e93..bad6b878d54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,8 @@ cmake_minimum_required(VERSION 2.6) project(Blender) +enable_testing() + #----------------------------------------------------------------------------- # Redirect output files diff --git a/SConstruct b/SConstruct index 6fb311daac0..48397347073 100644 --- a/SConstruct +++ b/SConstruct @@ -28,6 +28,8 @@ # Main entry-point for the SCons building system # Set up some custom actions and target/argument handling # Then read all SConscripts and build +# +# TODO: fix /FORCE:MULTIPLE on windows to get proper debug builds. import platform as pltfrm diff --git a/build_files/cmake/cmake_consistency_check.py b/build_files/cmake/cmake_consistency_check.py index 68b5fc0bcce..7a3ac9eaa79 100644 --- a/build_files/cmake/cmake_consistency_check.py +++ b/build_files/cmake/cmake_consistency_check.py @@ -141,6 +141,9 @@ def cmake_get_src(f): sources_h.append(new_file) elif is_c(new_file): sources_c.append(new_file) + elif l in ("PARENT_SCOPE", ): + # cmake var, ignore + pass else: raise Exception("unknown file type - not c or h %s -> %s" % (f, new_file)) diff --git a/doc/manpage/blender.1 b/doc/manpage/blender.1 index 9265fbc190a..8338b41559e 100644 --- a/doc/manpage/blender.1 +++ b/doc/manpage/blender.1 @@ -1,4 +1,4 @@ -.TH "BLENDER" "1" "January 01, 2011" "Blender Blender 2\&.56 (sub 0) " +.TH "BLENDER" "1" "January 20, 2011" "Blender Blender 2\&.56 (sub 0) " .SH NAME blender \- a 3D modelling and rendering package @@ -133,17 +133,9 @@ Use amount of <threads> for rendering in background .SS "Animation Playback Options:" .TP -.B \-a <options> <file(s)> -.br -Playback <file(s)>, only operates this way when not running in background. -.br - \-p <sx> <sy> Open with lower left corner at <sx>, <sy> -.br - \-m Read from disk (Don't buffer) -.br - \-f <fps> <fps\-base> Specify FPS to start with +.B \-a or \-\-render\-anim .br - \-j <frame> Set frame step to <frame> +Render frames from start to end (inclusive) .br .IP @@ -211,6 +203,46 @@ Enable floating point exceptions .IP .TP +.B \-\-factory\-startup +.br +Skip reading the "startup.blend" in the users home directory +.br + +.IP + +.TP +.B \-\-env\-system\-config +.br +Set the BLENDER_SYSTEM_CONFIG environment variable +.br + +.TP +.B \-\-env\-system\-datafiles +.br +Set the BLENDER_SYSTEM_DATAFILES environment variable +.br + +.TP +.B \-\-env\-system\-scripts +.br +Set the BLENDER_SYSTEM_SCRIPTS environment variable +.br + +.TP +.B \-\-env\-system\-plugins +.br +Set the BLENDER_SYSTEM_PLUGINS environment variable +.br + +.TP +.B \-\-env\-system\-python +.br +Set the BLENDER_SYSTEM_PYTHON environment variable +.br + +.IP + +.TP .B \-nojoystick .br Disable joystick support @@ -293,6 +325,20 @@ Print this help text and exit (windows only) .br .TP +.B \-a <options> <file(s)> +.br +Playback <file(s)>, only operates this way when not running in background. +.br + \-p <sx> <sy> Open with lower left corner at <sx>, <sy> +.br + \-m Read from disk (Don't buffer) +.br + \-f <fps> <fps\-base> Specify FPS to start with +.br + \-j <frame> Set frame step to <frame> +.br + +.TP .B \-R .br Register .blend extension (windows only) diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp index 1fac1538769..203f5b7596c 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp @@ -61,10 +61,12 @@ void btScaledBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callb scaledAabbMin[0] = m_localScaling.getX() >= 0. ? aabbMin[0] * invLocalScaling[0] : aabbMax[0] * invLocalScaling[0]; scaledAabbMin[1] = m_localScaling.getY() >= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1]; scaledAabbMin[2] = m_localScaling.getZ() >= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2]; + scaledAabbMin[3] = 0.0; /* otherwise un-initialized stack memory: uninitialized_stack_vec.patch, blender patch */ scaledAabbMax[0] = m_localScaling.getX() <= 0. ? aabbMin[0] * invLocalScaling[0] : aabbMax[0] * invLocalScaling[0]; scaledAabbMax[1] = m_localScaling.getY() <= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1]; scaledAabbMax[2] = m_localScaling.getZ() <= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2]; + scaledAabbMax[3] = 0.0; /* otherwise un-initialized stack memory: uninitialized_stack_vec.patch, blender patch */ m_bvhTriMeshShape->processAllTriangles(&scaledCallback,scaledAabbMin,scaledAabbMax); diff --git a/extern/bullet2/uninitialized_stack_vec.patch b/extern/bullet2/uninitialized_stack_vec.patch new file mode 100644 index 00000000000..96833b717b7 --- /dev/null +++ b/extern/bullet2/uninitialized_stack_vec.patch @@ -0,0 +1,17 @@ +Index: src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp +=================================================================== +--- src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp (revision 34336) ++++ src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp (working copy) +@@ -61,10 +61,12 @@ + scaledAabbMin[0] = m_localScaling.getX() >= 0. ? aabbMin[0] * invLocalScaling[0] : aabbMax[0] * invLocalScaling[0]; + scaledAabbMin[1] = m_localScaling.getY() >= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1]; + scaledAabbMin[2] = m_localScaling.getZ() >= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2]; ++ scaledAabbMin[3] = 0.0; /* otherwise un-initialized stack memory: uninitialized_stack_vec.patch, blender patch */ + + scaledAabbMax[0] = m_localScaling.getX() <= 0. ? aabbMin[0] * invLocalScaling[0] : aabbMax[0] * invLocalScaling[0]; + scaledAabbMax[1] = m_localScaling.getY() <= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1]; + scaledAabbMax[2] = m_localScaling.getZ() <= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2]; ++ scaledAabbMax[3] = 0.0; /* otherwise un-initialized stack memory: uninitialized_stack_vec.patch, blender patch */ + + + m_bvhTriMeshShape->processAllTriangles(&scaledCallback,scaledAabbMin,scaledAabbMax); diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 08d83565e5c..bf401138cf1 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1356,7 +1356,7 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr) if (confirmOpen == NSAlertAlternateReturn) { - filenameTextSize = [filepath lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding]; + filenameTextSize = [filepath lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; temp_buff = (char*) malloc(filenameTextSize+1); @@ -1364,7 +1364,7 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr) return GHOST_kFailure; } - strncpy(temp_buff, [filepath cStringUsingEncoding:NSISOLatin1StringEncoding], filenameTextSize); + strncpy(temp_buff, [filepath cStringUsingEncoding:NSUTF8StringEncoding], filenameTextSize); temp_buff[filenameTextSize] = '\0'; diff --git a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp index 9f4ff98c799..a965906ebce 100644 --- a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp @@ -35,6 +35,29 @@ #include <windows.h> #include <shlobj.h> +#if defined(__MINGW32__) || defined(__CYGWIN__) + +#if !defined(SHARD_PIDL) +#define SHARD_PIDL 0x00000001L +#endif + +#if !defined(SHARD_PATHA) +#define SHARD_PATHA 0x00000002L +#endif + +#if !defined(SHARD_PATHA) +#define SHARD_PATHW 0x00000003L +#endif + +#if !defined(SHARD_PATH) +#ifdef UNICODE +#define SHARD_PATH SHARD_PATHW +#else +#define SHARD_PATH SHARD_PATHA +#endif +#endif + +#endif GHOST_SystemPathsWin32::GHOST_SystemPathsWin32() { @@ -82,7 +105,6 @@ const GHOST_TUns8* GHOST_SystemPathsWin32::getBinaryDir() const void GHOST_SystemPathsWin32::addToSystemRecentFiles(const char* filename) const { - /* SHARD_PATHA is for ansi strings, use SHARD_PATHW for wide */ - SHAddToRecentDocs(SHARD_PATHA,filename); - + /* SHARD_PATH resolves to SHARD_PATHA for non-UNICODE build */ + SHAddToRecentDocs(SHARD_PATH,filename); } diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index db08f238045..8d28c9d5b17 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -498,7 +498,7 @@ void GHOST_WindowCocoa::setTitle(const STR_String& title) GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setTitle(): window invalid") NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSString *windowTitle = [[NSString alloc] initWithCString:title encoding:NSISOLatin1StringEncoding]; + NSString *windowTitle = [[NSString alloc] initWithCString:title encoding:NSUTF8StringEncoding]; //Set associated file if applicable if (windowTitle && [windowTitle hasPrefix:@"Blender"]) @@ -517,7 +517,7 @@ void GHOST_WindowCocoa::setTitle(const STR_String& title) [m_window setTitle:[associatedFileName lastPathComponent]]; //Blender used file open/save functions converte file names into legal URL ones - associatedFileName = [associatedFileName stringByAddingPercentEscapesUsingEncoding:NSISOLatin1StringEncoding]; + associatedFileName = [associatedFileName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; @try { [m_window setRepresentedFilename:associatedFileName]; } diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index b877470d710..6830db8241c 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -342,13 +342,15 @@ GHOST_WindowX11( // we want this window treated. XSizeHints * xsizehints = XAllocSizeHints(); - xsizehints->flags = PPosition | PSize | PMinSize; + xsizehints->flags = PPosition | PSize | PMinSize | PMaxSize; xsizehints->x = left; xsizehints->y = top; xsizehints->width = width; xsizehints->height = height; xsizehints->min_width= 320; // size hints, could be made apart of the ghost api xsizehints->min_height= 240; // limits are also arbitrary, but should not allow 1x1 window + xsizehints->max_width= 65535; + xsizehints->max_height= 65535; XSetWMNormalHints(m_display, m_window, xsizehints); XFree(xsizehints); diff --git a/intern/iksolver/intern/IK_QSegment.h b/intern/iksolver/intern/IK_QSegment.h index 84bebce5097..f6073a94a96 100644 --- a/intern/iksolver/intern/IK_QSegment.h +++ b/intern/iksolver/intern/IK_QSegment.h @@ -34,7 +34,6 @@ #include "MT_Transform.h" #include "MT_Matrix4x4.h" #include "IK_QJacobian.h" -#include "MEM_SmartPtr.h" #include <vector> diff --git a/intern/memutil/MEM_Allocator.h b/intern/memutil/MEM_Allocator.h index 925b6b42318..56c5fc80035 100644 --- a/intern/memutil/MEM_Allocator.h +++ b/intern/memutil/MEM_Allocator.h @@ -21,18 +21,12 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifndef __MEM_Allocator_h_included__ -#define __MEM_Allocator_h_included__ 1 +#ifndef MEM_ALLOCATOR_H +#define MEM_ALLOCATOR_H #include "guardedalloc/MEM_guardedalloc.h" #include "guardedalloc/BLO_sys_types.h" -#ifdef _MSC_VER -#if _MSC_VER < 1300 // 1200 == VC++ 6.0 according to boost -#define MS_VISUALC_6_0_WORKAROUND 1 -#endif -#endif - template<typename _Tp> struct MEM_Allocator { @@ -44,20 +38,16 @@ struct MEM_Allocator typedef const _Tp& const_reference; typedef _Tp value_type; -#ifndef MS_VISUALC_6_0_WORKAROUND template<typename _Tp1> struct rebind { typedef MEM_Allocator<_Tp1> other; }; -#endif MEM_Allocator() throw() {} MEM_Allocator(const MEM_Allocator&) throw() {} -#ifndef MS_VISUALC_6_0_WORKAROUND template<typename _Tp1> MEM_Allocator(const MEM_Allocator<_Tp1>) throw() { } -#endif ~MEM_Allocator() throw() {} @@ -65,11 +55,6 @@ struct MEM_Allocator const_pointer address(const_reference __x) const { return &__x; } -#ifdef MS_VISUALC_6_0_WORKAROUND - char *_Charalloc(size_type n) { - return (char *) MEM_mallocN(n, "STL MEM_Allocator VC6.0"); - } -#endif // NB: __n is permitted to be 0. The C++ standard says nothing // about what the return value is when __n == 0. _Tp* allocate(size_type __n, const void* = 0) { @@ -81,17 +66,10 @@ struct MEM_Allocator return __ret; } -#ifndef MS_VISUALC_6_0_WORKAROUND // __p is not permitted to be a null pointer. void deallocate(pointer __p, size_type){ MEM_freeN(__p); } -#else - // __p is not permitted to be a null pointer. - void deallocate(void* __p, size_type){ - MEM_freeN(__p); - } -#endif size_type max_size() const throw() { return size_t(-1) / sizeof(_Tp); @@ -106,4 +84,4 @@ struct MEM_Allocator } }; -#endif +#endif // MEM_ALLOCATOR_H diff --git a/intern/memutil/MEM_CacheLimiter.h b/intern/memutil/MEM_CacheLimiter.h index 0a7ac8d6629..b90c5db1b4f 100644 --- a/intern/memutil/MEM_CacheLimiter.h +++ b/intern/memutil/MEM_CacheLimiter.h @@ -21,8 +21,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifndef __MEM_cache_limiter_h_included__ -#define __MEM_cache_limiter_h_included__ 1 +#ifndef MEM_CACHELIMITER_H +#define MEM_CACHELIMITER_H /** * @section MEM_CacheLimiter @@ -164,4 +164,4 @@ private: MEM_Allocator<MEM_CacheLimiterHandle<T> *> > queue; }; -#endif +#endif // MEM_CACHELIMITER_H diff --git a/intern/memutil/MEM_CacheLimiterC-Api.h b/intern/memutil/MEM_CacheLimiterC-Api.h index 0e53a0b0e0d..4116d05e42f 100644 --- a/intern/memutil/MEM_CacheLimiterC-Api.h +++ b/intern/memutil/MEM_CacheLimiterC-Api.h @@ -21,8 +21,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifndef __MEM_cache_limiter_c_api_h_included__ -#define __MEM_cache_limiter_c_api_h_included__ 1 +#ifndef MEM_CACHELIMITERC_API_H +#define MEM_CACHELIMITERC_API_H #ifdef __cplusplus extern "C" { @@ -37,10 +37,10 @@ typedef struct MEM_CacheLimiterHandle_s MEM_CacheLimiterHandleC; /* function used to remove data from memory */ typedef void(*MEM_CacheLimiter_Destruct_Func)(void*); -#ifndef __MEM_cache_limiter_h_included__ +#ifndef MEM_CACHELIMITER_H extern void MEM_CacheLimiter_set_maximum(int m); extern int MEM_CacheLimiter_get_maximum(void); -#endif +#endif // MEM_CACHELIMITER_H /** * Create new MEM_CacheLimiter object * managed objects are destructed with the data_destructor @@ -137,5 +137,4 @@ extern void * MEM_CacheLimiter_get(MEM_CacheLimiterHandleC * handle); #endif -#endif - +#endif // MEM_CACHELIMITERC_API_H diff --git a/intern/memutil/MEM_RefCounted.h b/intern/memutil/MEM_RefCounted.h index e369aa122e6..64aceef6f3c 100644 --- a/intern/memutil/MEM_RefCounted.h +++ b/intern/memutil/MEM_RefCounted.h @@ -30,8 +30,8 @@ * Declaration of MEM_RefCounted class. */ -#ifndef _H_MEM_REF_COUNTED -#define _H_MEM_REF_COUNTED +#ifndef MEM_REFCOUNTED_H +#define MEM_REFCOUNTED_H /** * An object with reference counting. @@ -108,5 +108,5 @@ inline int MEM_RefCounted::decRef() return m_refCount; } -#endif // _H_MEM_REF_COUNTED +#endif // MEM_REFCOUNTED_H diff --git a/intern/memutil/MEM_RefCountedC-Api.h b/intern/memutil/MEM_RefCountedC-Api.h index 387c00afbf1..900b5083e09 100644 --- a/intern/memutil/MEM_RefCountedC-Api.h +++ b/intern/memutil/MEM_RefCountedC-Api.h @@ -30,8 +30,8 @@ * Interface for C access to functionality relating to shared objects in the foundation library. */ -#ifndef _H_MEM_REF_COUNTED_C_API -#define _H_MEM_REF_COUNTED_C_API +#ifndef MEM_REFCOUNTEDC_API_H +#define MEM_REFCOUNTEDC_API_H /** A pointer to a private object. */ typedef struct MEM_TOpaqueObject* MEM_TObjectPtr; @@ -71,5 +71,4 @@ extern int MEM_RefCountedDecRef(MEM_TRefCountedObjectPtr shared); } #endif -#endif // _H_MEM_REF_COUNTED_C_API - +#endif // MEM_REFCOUNTEDC_API_H diff --git a/release/bin/blender-thumbnailer.py b/release/bin/blender-thumbnailer.py index be870560110..16a89d29724 100755 --- a/release/bin/blender-thumbnailer.py +++ b/release/bin/blender-thumbnailer.py @@ -27,18 +27,19 @@ To run automatically with nautilus: import struct + def blend_extract_thumb(path): import os # def MAKE_ID(tag): ord(tag[0])<<24 | ord(tag[1])<<16 | ord(tag[2])<<8 | ord(tag[3]) - REND = 1145980242 # MAKE_ID(b'REND') - TEST = 1414743380 # MAKE_ID(b'TEST') + REND = 1145980242 # MAKE_ID(b'REND') + TEST = 1414743380 # MAKE_ID(b'TEST') blendfile = open(path, 'rb') head = blendfile.read(12) - if head[0:2] == b'\x1f\x8b': # gzip magic + if head[0:2] == b'\x1f\x8b': # gzip magic import gzip blendfile.close() blendfile = gzip.open(path, 'rb') @@ -48,10 +49,10 @@ def blend_extract_thumb(path): blendfile.close() return None, 0, 0 - is_64_bit = (head[7] == b'-') + is_64_bit = (head[7] == b'-'[0]) # true for PPC, false for X86 - is_big_endian = (head[8] == b'V') + is_big_endian = (head[8] == b'V'[0]) # blender pre 2.5 had no thumbs if head[9:11] <= b'24': @@ -66,23 +67,22 @@ def blend_extract_thumb(path): if len(bhead) < sizeof_bhead: return None, 0, 0 - code, length = struct.unpack(int_endian_pair, bhead[0:8]) # 8 == sizeof(int) * 2 + code, length = struct.unpack(int_endian_pair, bhead[0:8]) # 8 == sizeof(int) * 2 if code == REND: blendfile.seek(length, os.SEEK_CUR) else: break - - + if code != TEST: return None, 0, 0 try: - x, y = struct.unpack(int_endian_pair, blendfile.read(8)) # 8 == sizeof(int) * 2 + x, y = struct.unpack(int_endian_pair, blendfile.read(8)) # 8 == sizeof(int) * 2 except struct.error: return None, 0, 0 - length -= 8 # sizeof(int) * 2 + length -= 8 # sizeof(int) * 2 if length != x * y * 4: return None, 0, 0 @@ -122,7 +122,7 @@ if __name__ == '__main__': file_in = sys.argv[-2] buf, width, height = blend_extract_thumb(file_in) - + if buf: file_out = sys.argv[-1] diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py index 044052883c6..e131be648ce 100644 --- a/release/scripts/modules/bpy/path.py +++ b/release/scripts/modules/bpy/path.py @@ -27,12 +27,15 @@ import bpy as _bpy import os as _os -def abspath(path): +def abspath(path, start=None): """ Returns the absolute path relative to the current blend file using the "//" prefix. + + :arg start: Relative to this path, when not set the current filename is used. + :type start: string """ if path.startswith("//"): - return _os.path.join(_os.path.dirname(_bpy.data.filepath), path[2:]) + return _os.path.join(_os.path.dirname(_bpy.data.filepath if start is None else start), path[2:]) return path diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index a2c3d416b23..61c3f11ccef 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -302,18 +302,25 @@ def ord_ind(i1, i2): class Mesh(bpy_types.ID): __slots__ = () - def from_pydata(self, verts, edges, faces): + def from_pydata(self, vertices, edges, faces): """ Make a mesh from a list of verts/edges/faces Until we have a nicer way to make geometry, use this. + + :arg vertices: float triplets each representing (X, Y, Z) eg: [(0.0, 1.0, 0.5), ...]. + :type vertices: iterable object + :arg edges: int pairs, each pair contains two indices to the *vertices* argument. eg: [(1, 2), ...] + :type edges: iterable object + :arg faces: iterator of faces, each faces contains three or four indices to the *vertices* argument. eg: [(5, 6, 8, 9), (1, 2, 3), ...] + :type faces: iterable object """ - self.vertices.add(len(verts)) + self.vertices.add(len(vertices)) self.edges.add(len(edges)) self.faces.add(len(faces)) - verts_flat = [f for v in verts for f in v] - self.vertices.foreach_set("co", verts_flat) - del verts_flat + vertices_flat = [f for v in vertices for f in v] + self.vertices.foreach_set("co", vertices_flat) + del vertices_flat edges_flat = [i for e in edges for i in e] self.edges.foreach_set("vertices", edges_flat) diff --git a/release/scripts/op/io_shape_mdd/__init__.py b/release/scripts/op/io_shape_mdd/__init__.py deleted file mode 100644 index a48d16d87a6..00000000000 --- a/release/scripts/op/io_shape_mdd/__init__.py +++ /dev/null @@ -1,120 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -# <pep8 compliant> - -# To support reload properly, try to access a package var, if it's there, reload everything -if "bpy" in locals(): - import imp - if "import_mdd" in locals(): - imp.reload(import_mdd) - if "export_mdd" in locals(): - imp.reload(export_mdd) - - -import bpy -from bpy.props import * -from io_utils import ExportHelper, ImportHelper - - -class ImportMDD(bpy.types.Operator, ImportHelper): - '''Import MDD vertex keyframe file to shape keys''' - bl_idname = "import_shape.mdd" - bl_label = "Import MDD" - - filename_ext = ".mdd" - filter_glob = StringProperty(default="*.mdd", options={'HIDDEN'}) - - frame_start = IntProperty(name="Start Frame", description="Start frame for inserting animation", min=-300000, max=300000, default=0) - frame_step = IntProperty(name="Step", min=1, max=1000, default=1) - - @classmethod - def poll(cls, context): - ob = context.active_object - return (ob and ob.type == 'MESH') - - def execute(self, context): - - # initialize from scene if unset - scene = context.scene - if not self.frame_start: - self.frame_start = scene.frame_current - - from . import import_mdd - return import_mdd.load(self, context, **self.as_keywords(ignore=("filter_glob",))) - - -class ExportMDD(bpy.types.Operator, ExportHelper): - '''Animated mesh to MDD vertex keyframe file''' - bl_idname = "export_shape.mdd" - bl_label = "Export MDD" - - filename_ext = ".mdd" - filter_glob = StringProperty(default="*.mdd", options={'HIDDEN'}) - - # get first scene to get min and max properties for frames, fps - - minframe = 1 - maxframe = 300000 - minfps = 1 - maxfps = 120 - - # List of operator properties, the attributes will be assigned - # to the class instance from the operator settings before calling. - fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default=25) - frame_start = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe, max=maxframe, default=1) - frame_end = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default=250) - - @classmethod - def poll(cls, context): - obj = context.active_object - return (obj and obj.type == 'MESH') - - def execute(self, context): - # initialize from scene if unset - scene = context.scene - if not self.frame_start: - self.frame_start = scene.frame_start - if not self.frame_end: - self.frame_end = scene.frame_end - if not self.fps: - self.fps = scene.render.fps - - from . import export_mdd - return export_mdd.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob"))) - - -def menu_func_import(self, context): - self.layout.operator(ImportMDD.bl_idname, text="Lightwave Point Cache (.mdd)") - - -def menu_func_export(self, context): - self.layout.operator(ExportMDD.bl_idname, text="Lightwave Point Cache (.mdd)") - - -def register(): - bpy.types.INFO_MT_file_import.append(menu_func_import) - bpy.types.INFO_MT_file_export.append(menu_func_export) - - -def unregister(): - bpy.types.INFO_MT_file_import.remove(menu_func_import) - bpy.types.INFO_MT_file_export.remove(menu_func_export) - -if __name__ == "__main__": - register() diff --git a/release/scripts/op/io_shape_mdd/export_mdd.py b/release/scripts/op/io_shape_mdd/export_mdd.py deleted file mode 100644 index 42795d450ab..00000000000 --- a/release/scripts/op/io_shape_mdd/export_mdd.py +++ /dev/null @@ -1,130 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -# <pep8 compliant> - -# Contributors: Bill L.Nieuwendorp - -""" -This script Exports Lightwaves MotionDesigner format. - -The .mdd format has become quite a popular Pipeline format<br> -for moving animations from package to package. - -Be sure not to use modifiers that change the number or order of verts in the mesh -""" - -import bpy -import mathutils -from struct import pack - - -def zero_file(filepath): - ''' - If a file fails, this replaces it with 1 char, better not remove it? - ''' - file = open(filepath, 'w') - file.write('\n') # apparently macosx needs some data in a blank file? - file.close() - - -def check_vertcount(mesh, vertcount): - ''' - check and make sure the vertcount is consistent throughout the frame range - ''' - if len(mesh.vertices) != vertcount: - raise Exception('Error, number of verts has changed during animation, cannot export') - f.close() - zero_file(filepath) - return - - -def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25): - """ - Blender.Window.WaitCursor(1) - - mesh_orig = Mesh.New() - mesh_orig.getFromObject(obj.name) - """ - - scene = context.scene - obj = context.object - - if bpy.ops.object.mode_set.poll(): - bpy.ops.object.mode_set(mode='OBJECT') - - orig_frame = scene.frame_current - scene.frame_set(frame_start) - me = obj.create_mesh(scene, True, 'PREVIEW') - - #Flip y and z - mat_flip = mathutils.Matrix(((1.0, 0.0, 0.0, 0.0), \ - (0.0, 0.0, 1.0, 0.0), \ - (0.0, 1.0, 0.0, 0.0), \ - (0.0, 0.0, 0.0, 1.0), \ - )) - - numverts = len(me.vertices) - - numframes = frame_end - frame_start + 1 - fps = float(fps) - f = open(filepath, 'wb') # no Errors yet:Safe to create file - - # Write the header - f.write(pack(">2i", numframes, numverts)) - - # Write the frame times (should we use the time IPO??) - f.write(pack(">%df" % (numframes), *[frame / fps for frame in range(numframes)])) # seconds - - #rest frame needed to keep frames in sync - """ - Blender.Set('curframe', frame_start) - me_tmp.getFromObject(obj.name) - """ - - check_vertcount(me, numverts) - me.transform(mat_flip * obj.matrix_world) - f.write(pack(">%df" % (numverts * 3), *[axis for v in me.vertices for axis in v.co])) - - for frame in range(frame_start, frame_end + 1): # in order to start at desired frame - """ - Blender.Set('curframe', frame) - me_tmp.getFromObject(obj.name) - """ - - scene.frame_set(frame) - me = obj.create_mesh(scene, True, 'PREVIEW') - check_vertcount(me, numverts) - me.transform(mat_flip * obj.matrix_world) - - # Write the vertex data - f.write(pack(">%df" % (numverts * 3), *[axis for v in me.vertices for axis in v.co])) - - """ - me_tmp.vertices= None - """ - f.close() - - print('MDD Exported: %r frames:%d\n' % (filepath, numframes - 1)) - """ - Blender.Window.WaitCursor(0) - Blender.Set('curframe', orig_frame) - """ - scene.frame_set(orig_frame) - - return {'FINISHED'} diff --git a/release/scripts/op/io_shape_mdd/import_mdd.py b/release/scripts/op/io_shape_mdd/import_mdd.py deleted file mode 100644 index 02be14e97fa..00000000000 --- a/release/scripts/op/io_shape_mdd/import_mdd.py +++ /dev/null @@ -1,102 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -# <pep8 compliant> - -# mdd importer by Bill L.Nieuwendorp -# conversion to blender 2.5: Ivo Grigull (loolarge) -# -# Warning if the vertex order or vertex count differs from the -# origonal model the mdd was Baked out from their will be Strange -# behavior -# -# vertex animation to ShapeKeys with ipo and gives the frame a value of 1.0 -# A modifier to read mdd files would be Ideal but thats for another day :) -# -# Please send any fixes,updates,bugs to Slow67_at_Gmail.com -# Bill Niewuendorp - -import bpy -from struct import unpack - - -def load(operator, context, filepath, frame_start=0, frame_step=1): - - scene = context.scene - obj = context.object - - print('\n\nimporting mdd %r' % filepath) - - if bpy.ops.object.mode_set.poll(): - bpy.ops.object.mode_set(mode='OBJECT') - - file = open(filepath, 'rb') - frames, points = unpack(">2i", file.read(8)) - time = unpack((">%df" % frames), file.read(frames * 4)) - - print('\tpoints:%d frames:%d' % (points, frames)) - - # If target object doesn't have Basis shape key, create it. - try: - num_keys = len(obj.data.shape_keys.keys) - except: - basis = obj.shape_key_add() - basis.name = "Basis" - obj.data.update() - - scene.frame_current = frame_start - - def UpdateMesh(ob, fr): - - # Insert new shape key - new_shapekey = obj.shape_key_add() - new_shapekey.name = ("frame_%.4d" % fr) - new_shapekey_name = new_shapekey.name - - obj.active_shape_key_index = len(obj.data.shape_keys.keys) - 1 - index = len(obj.data.shape_keys.keys) - 1 - obj.show_only_shape_key = True - - verts = obj.data.shape_keys.keys[len(obj.data.shape_keys.keys) - 1].data - - for v in verts: # 12 is the size of 3 floats - v.co[:] = unpack('>3f', file.read(12)) - #me.update() - obj.show_only_shape_key = False - - # insert keyframes - shape_keys = obj.data.shape_keys - - scene.frame_current -= 1 - obj.data.shape_keys.keys[index].value = 0.0 - shape_keys.keys[len(obj.data.shape_keys.keys) - 1].keyframe_insert("value") - - scene.frame_current += 1 - obj.data.shape_keys.keys[index].value = 1.0 - shape_keys.keys[len(obj.data.shape_keys.keys) - 1].keyframe_insert("value") - - scene.frame_current += 1 - obj.data.shape_keys.keys[index].value = 0.0 - shape_keys.keys[len(obj.data.shape_keys.keys) - 1].keyframe_insert("value") - - obj.data.update() - - for i in range(frames): - UpdateMesh(obj, i) - - return {'FINISHED'} diff --git a/release/scripts/op/uvcalc_follow_active.py b/release/scripts/op/uvcalc_follow_active.py index a8aa9b12215..10b40aa4538 100644 --- a/release/scripts/op/uvcalc_follow_active.py +++ b/release/scripts/op/uvcalc_follow_active.py @@ -190,7 +190,7 @@ def extend(obj, operator, EXTEND_MODE): # Done finding seams # face connectivity - faces around each face - # only store a list of indicies for each face. + # only store a list of indices for each face. face_faces = [[] for i in range(len(face_sel))] for edge_key, faces in edge_faces.items(): diff --git a/release/scripts/op/wm.py b/release/scripts/op/wm.py index f6cd30edb05..38fead4ecf8 100644 --- a/release/scripts/op/wm.py +++ b/release/scripts/op/wm.py @@ -750,7 +750,7 @@ class WM_OT_properties_edit(bpy.types.Operator): self.description = prop_ui.get("description", "") wm = context.window_manager - return wm.invoke_props_popup(self, event) + return wm.invoke_props_dialog(self) class WM_OT_properties_add(bpy.types.Operator): diff --git a/release/scripts/ui/properties_particle.py b/release/scripts/ui/properties_particle.py index 2e3068ec0fb..9cde2891177 100644 --- a/release/scripts/ui/properties_particle.py +++ b/release/scripts/ui/properties_particle.py @@ -41,7 +41,7 @@ def particle_panel_poll(cls, context): return False if psys.settings is None: return False - return psys.settings.type in ('EMITTER', 'REACTOR', 'HAIR') and (engine in cls.COMPAT_ENGINES) + return psys.settings.is_fluid == False and (engine in cls.COMPAT_ENGINES) class ParticleButtonsPanel(): @@ -95,13 +95,13 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, bpy.types.Panel): split = layout.split(percentage=0.32) col = split.column() col.label(text="Name:") - if part.type in ('EMITTER', 'REACTOR', 'HAIR'): + if part.is_fluid == False: col.label(text="Settings:") col.label(text="Type:") col = split.column() col.prop(psys, "name", text="") - if part.type in ('EMITTER', 'REACTOR', 'HAIR'): + if part.is_fluid == False: row = col.row() row.enabled = particle_panel_enabled(context, psys) row.template_ID(psys, "settings", new="particle.new") @@ -111,8 +111,8 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, bpy.types.Panel): #row.label(text="Render") if part: - if part.type not in ('EMITTER', 'REACTOR', 'HAIR'): - layout.label(text="No settings for fluid particles") + if part.is_fluid: + layout.label(text=str(part.count) + " fluid particles for this frame.") return row = col.row() @@ -150,10 +150,16 @@ class PARTICLE_PT_emission(ParticleButtonsPanel, bpy.types.Panel): @classmethod def poll(cls, context): + psys = context.particle_system + if psys is None: + return False + if psys.settings is None: + return False + if psys.settings.is_fluid: + return False if particle_panel_poll(PARTICLE_PT_emission, context): return not context.particle_system.point_cache.use_external - else: - return False + return False def draw(self, context): layout = self.layout @@ -273,6 +279,8 @@ class PARTICLE_PT_cache(ParticleButtonsPanel, bpy.types.Panel): return False if psys.settings is None: return False + if psys.settings.is_fluid: + return False phystype = psys.settings.physics_type if phystype == 'NO' or phystype == 'KEYED': return False @@ -1011,6 +1019,10 @@ class PARTICLE_PT_field_weights(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Field Weights" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} + + @classmethod + def poll(cls, context): + return particle_panel_poll(cls, context) def draw(self, context): part = context.particle_system.settings @@ -1052,6 +1064,10 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Vertexgroups" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} + + @classmethod + def poll(cls, context): + return particle_panel_poll(cls, context) def draw(self, context): layout = self.layout diff --git a/release/scripts/ui/space_nla.py b/release/scripts/ui/space_nla.py index 5994b1dcc01..1921e80035d 100644 --- a/release/scripts/ui/space_nla.py +++ b/release/scripts/ui/space_nla.py @@ -137,8 +137,10 @@ class NLA_MT_edit(bpy.types.Menu): layout.separator() layout.operator("nla.apply_scale") layout.operator("nla.clear_scale") + layout.operator("nla.action_sync_length").active = False layout.separator() + layout.operator("nla.swap") layout.operator("nla.move_up") layout.operator("nla.move_down") diff --git a/release/scripts/ui/space_sequencer.py b/release/scripts/ui/space_sequencer.py index 3a9df992b57..110cb74d3c5 100644 --- a/release/scripts/ui/space_sequencer.py +++ b/release/scripts/ui/space_sequencer.py @@ -611,10 +611,11 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, bpy.types.Panel): col.prop(strip.crop, "min_y") col.prop(strip.crop, "max_x") - col = layout.column(align=True) - col.label(text="Trim Duration (hard):") - col.prop(strip, "animation_offset_start", text="Start") - col.prop(strip, "animation_offset_end", text="End") + if not isinstance(strip, bpy.types.EffectSequence): + col = layout.column(align=True) + col.label(text="Trim Duration (hard):") + col.prop(strip, "animation_offset_start", text="Start") + col.prop(strip, "animation_offset_end", text="End") col = layout.column(align=True) col.label(text="Trim Duration (soft):") diff --git a/release/scripts/ui/space_view3d_toolbar.py b/release/scripts/ui/space_view3d_toolbar.py index a115d230e27..8d9d1212eee 100644 --- a/release/scripts/ui/space_view3d_toolbar.py +++ b/release/scripts/ui/space_view3d_toolbar.py @@ -417,7 +417,6 @@ class VIEW3D_PT_tools_posemode_options(View3DPanel, bpy.types.Panel): arm = context.active_object.data col = layout.column(align=True) - col.prop(arm, "use_mirror_x") col.prop(arm, "use_auto_ik") # ********** default tools for paint modes **************** diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index c13abb862b7..46e1405df84 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -34,3 +34,5 @@ endif() if(WINDOWS) add_subdirectory(icons) endif() + +add_subdirectory(test) diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 65567262441..d222fe8d296 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -61,7 +61,8 @@ typedef struct Global { struct ListBase recent_files; short afbreek, moving, file_loaded; - short background; + char background; + char factory_startup; short winpos, displaymode; /* used to be in Render */ short rendering; /* to indicate render is busy, prevent renderwindow events etc */ @@ -91,10 +92,6 @@ typedef struct Global { /* ndof device found ? */ int ndofdevice; - - /* confusing... G.f and G.flags */ - int flags; - } Global; /* **************** GLOBAL ********************* */ diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index f072a942216..3f7523d5264 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -312,7 +312,7 @@ void reset_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, /* psys_reset */ #define PSYS_RESET_ALL 1 #define PSYS_RESET_DEPSGRAPH 2 -#define PSYS_RESET_CHILDREN 3 +/* #define PSYS_RESET_CHILDREN 3 */ /*UNUSED*/ #define PSYS_RESET_CACHE_MISS 4 /* index_dmcache */ diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index c8e967e8a9a..e4623a31807 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -45,7 +45,7 @@ #define PTCACHE_RESET_DEPSGRAPH 0 #define PTCACHE_RESET_BAKED 1 #define PTCACHE_RESET_OUTDATED 2 -#define PTCACHE_RESET_FREE 3 +/* #define PTCACHE_RESET_FREE 3 */ /*UNUSED*/ /* Add the blendfile name after blendcache_ */ #define PTCACHE_EXT ".bphys" diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index bee0b476f9f..c733a560620 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2237,7 +2237,7 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) { Object *obact = scene->basact?scene->basact->object:NULL; int editing = paint_facesel_test(ob); - /* weight paint and face select need original indicies because of selection buffer drawing */ + /* weight paint and face select need original indices because of selection buffer drawing */ int needMapping = (ob==obact) && (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT|OB_MODE_VERTEX_PAINT))); clear_mesh_caches(ob); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 56869e503dd..6e08df0f465 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -160,7 +160,7 @@ static void clean_paths(Main *main) char filepath_expanded[1024]; Scene *scene; - for(BLI_bpathIterator_init(&bpi, main, main->name); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) { + for(BLI_bpathIterator_init(&bpi, main, main->name, BPATH_USE_PACKED); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) { BLI_bpathIterator_getPath(bpi, filepath_expanded); BLI_clean(filepath_expanded); @@ -299,8 +299,6 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename /* these are the same at times, should never copy to the same location */ if(G.main->name != filename) BLI_strncpy(G.main->name, filename, FILE_MAX); - - BLI_strncpy(G.main->name, filename, FILE_MAX); /* is guaranteed current file */ /* baseflags, groups, make depsgraph, etc */ set_scene_bg(G.main, CTX_data_scene(C)); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 87dff0a58b6..ef1ac582c1e 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -221,7 +221,7 @@ FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array for (fcu= list->first; fcu; fcu= fcu->next) { /* simple string-compare (this assumes that they have the same root...) */ if (fcu->rna_path && !strcmp(fcu->rna_path, rna_path)) { - /* now check indicies */ + /* now check indices */ if (fcu->array_index == array_index) return fcu; } diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index fc9c41070dc..8004f23c22a 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1317,8 +1317,9 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, VECSUB(extent, X[s->ij], tvect); - dot = INPR(extent, extent); - length = sqrt(dot); + // SEE MSG BELOW (these are UNUSED) + // dot = INPR(extent, extent); + // length = sqrt(dot); k = clmd->sim_parms->goalspring; diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index b4dd81ce356..db995fd4f1d 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -315,7 +315,7 @@ static const char *constraint_adrcodes_to_paths (int adrcode, int *array_index) /* ShapeKey types * NOTE: as we don't have access to the keyblock where the data comes from (for now), - * we'll just use numerical indicies for now... + * we'll just use numerical indices for now... */ static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) { diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 6e48b922424..a22fc165de7 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -1422,7 +1422,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) int i, j, k, c_i, c_j, c_k; int index[3]={1,0,-1}; float f =0.0f; - float in_v, out_v; + float in_v /*, out_v*/; MB_POINT workp; float tmp_v, workp_v, max_len, len, dx, dy, dz, nx, ny, nz, MAXN; @@ -1483,7 +1483,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) calc_mballco(ml, (float *)&out); - out_v = mbproc->function(out.x, out.y, out.z); + /*out_v = mbproc->function(out.x, out.y, out.z);*/ /*UNUSED*/ /* find "first points" on Implicit Surface of MetaElemnt ml */ workp.x = in.x; @@ -1582,8 +1582,8 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ Object *bob; MetaBall *mb; MetaElem *ml; - float size, totsize, (*mat)[4] = NULL, (*imat)[4] = NULL, obinv[4][4], obmat[4][4], vec[3]; - float temp1[4][4], temp2[4][4], temp3[4][4]; //max=0.0; + float size, totsize, obinv[4][4], obmat[4][4], vec[3]; + //float max=0.0; int a, obnr, zero_size=0; char obname[32]; @@ -1602,7 +1602,6 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ ml= NULL; if(bob==ob && (base->flag & OB_FROMDUPLI)==0) { - mat= imat= 0; mb= ob->data; if(mb->editelems) ml= mb->editelems->first; @@ -1649,6 +1648,8 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ while(ml) { if(!(ml->flag & MB_HIDE)) { int i; + float temp1[4][4], temp2[4][4], temp3[4][4]; + float (*mat)[4] = NULL, (*imat)[4] = NULL; float max_x, max_y, max_z, min_x, min_y, min_z; max_x = max_y = max_z = -3.4e38; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 595614ef1e7..6db03909aa3 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -78,7 +78,7 @@ void free_nlastrip (ListBase *strips, NlaStrip *strip) /* remove reference to action */ if (strip->act) - strip->act->id.us--; + id_us_min(&strip->act->id); /* free remapping info */ //if (strip->remap) @@ -160,7 +160,7 @@ NlaStrip *copy_nlastrip (NlaStrip *strip) /* increase user-count of action */ if (strip_d->act) - strip_d->act->id.us++; + id_us_plus(&strip_d->act->id); /* copy F-Curves and modifiers */ copy_fcurves(&strip_d->fcurves, &strip->fcurves); @@ -514,7 +514,7 @@ short BKE_nlastrips_has_space (ListBase *strips, float start, float end) /* if start frame of strip is past the target end-frame, that means that * we've gone past the window we need to check for, so things are fine */ - if (strip->start > end) + if (strip->start >= end) return 1; /* if the end of the strip is greater than either of the boundaries, the range @@ -591,7 +591,7 @@ short BKE_nlastrips_add_strip (ListBase *strips, NlaStrip *strip) /* find the right place to add the strip to the nominated track */ for (ns= strips->first; ns; ns= ns->next) { /* if current strip occurs after the new strip, add it before */ - if (ns->start > strip->end) { + if (ns->start >= strip->end) { BLI_insertlinkbefore(strips, ns, strip); not_added= 0; break; @@ -683,7 +683,7 @@ void BKE_nlastrips_clear_metastrip (ListBase *strips, NlaStrip *strip) } /* free the meta-strip now */ - BLI_freelinkN(strips, strip); + free_nlastrip(strips, strip); } /* Remove meta-strips (i.e. flatten the list of strips) from the top-level of the list of strips @@ -1438,7 +1438,7 @@ void BKE_nla_action_pushdown (AnimData *adt) /* do other necessary work on strip */ if (strip) { /* clear reference to action now that we've pushed it onto the stack */ - adt->action->id.us--; + id_us_min(&adt->action->id); adt->action= NULL; /* if the strip is the first one in the track it lives in, check if there diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index c4d54cd6296..a6f03c0c3ec 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -615,6 +615,12 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) /* should become callbackable... */ void nodeVerifyGroup(bNodeTree *ngroup) { + /* XXX nodeVerifyGroup is sometimes called for non-group trees. + * This is not the best way to check if a tree is a group, + * trees should get their own flag for this! + */ + if (!ngroup->owntype) + return; /* group changed, so we rebuild the type definition */ ntreeMakeOwnType(ngroup); @@ -1082,15 +1088,61 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal) return nnode; } +/* fromsock and tosock can be NULL */ +/* also used via rna api, so we check for proper input output direction */ bNodeLink *nodeAddLink(bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, bNode *tonode, bNodeSocket *tosock) { - bNodeLink *link= MEM_callocN(sizeof(bNodeLink), "link"); + bNodeSocket *sock; + bNodeLink *link= NULL; + int from= 0, to= 0; + + if(fromsock) { + /* test valid input */ + for(sock= fromnode->outputs.first; sock; sock= sock->next) + if(sock==fromsock) + break; + if(sock) + from= 1; /* OK */ + else { + for(sock= fromnode->inputs.first; sock; sock= sock->next) + if(sock==fromsock) + break; + if(sock) + from= -1; /* OK but flip */ + } + } + if(tosock) { + for(sock= tonode->inputs.first; sock; sock= sock->next) + if(sock==tosock) + break; + if(sock) + to= 1; /* OK */ + else { + for(sock= tonode->outputs.first; sock; sock= sock->next) + if(sock==tosock) + break; + if(sock) + to= -1; /* OK but flip */ + } + } - BLI_addtail(&ntree->links, link); - link->fromnode= fromnode; - link->fromsock= fromsock; - link->tonode= tonode; - link->tosock= tosock; + /* this allows NULL sockets to work */ + if(from >= 0 && to >= 0) { + link= MEM_callocN(sizeof(bNodeLink), "link"); + BLI_addtail(&ntree->links, link); + link->fromnode= fromnode; + link->fromsock= fromsock; + link->tonode= tonode; + link->tosock= tosock; + } + else if(from <= 0 && to <= 0) { + link= MEM_callocN(sizeof(bNodeLink), "link"); + BLI_addtail(&ntree->links, link); + link->fromnode= tonode; + link->fromsock= tosock; + link->tonode= fromnode; + link->tosock= fromsock; + } return link; } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index b71338aaa70..4c436e8411f 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1684,7 +1684,7 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) normalize_qt_qt(tquat, ob->quat); quat_to_mat3(rmat, tquat); - normalize_qt_qt(tquat, ob->quat); + normalize_qt_qt(tquat, ob->dquat); quat_to_mat3(dmat, tquat); } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 5526edf0a8c..87c39abd561 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2743,7 +2743,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd { ParticleThread *pthreads; ParticleThreadContext *ctx; - ParticleCacheKey **cache; + /*ParticleCacheKey **cache;*/ /*UNUSED*/ ListBase threads; int i, totchild, totparent, totthread; @@ -2762,7 +2762,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd totparent= ctx->totparent; if(editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) { - cache = sim->psys->childcache; + /*cache = sim->psys->childcache;*/ /*UNUSED*/ } else { /* clear out old and create new empty path cache */ diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 06056e0ecc9..62bfde601f6 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3403,7 +3403,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) PARTICLE_P; float timestep; /* current time */ - float ctime; + /* float ctime; */ /*UNUSED*/ /* frame & time changes */ float dfra, dtime; float birthtime, dietime; @@ -3412,7 +3412,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) dfra= cfra - psys->cfra; timestep = psys_get_timestep(sim); - ctime= cfra*timestep; + /*ctime= cfra*timestep;*/ /*UNUSED*/ dtime= dfra*timestep; if(dfra<0.0){ @@ -3854,14 +3854,15 @@ static void system_step(ParticleSimulationData *sim, float cfra) return; } + /* Cache is supposed to be baked, but no data was found so bail out */ + else if(cache->flag & PTCACHE_BAKED) { + psys_reset(psys, PSYS_RESET_CACHE_MISS); + return; + } else if(cache_result == PTCACHE_READ_OLD) { psys->cfra = (float)cache->simframe; cached_step(sim, psys->cfra); } - else if(cfra != startframe && ( /*sim->ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED))) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */ - psys_reset(psys, PSYS_RESET_CACHE_MISS); - return; - } /* if on second frame, write cache for first frame */ if(psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index a22b36b9524..e623c095ac7 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -96,11 +96,9 @@ void BKE_report(ReportList *reports, ReportType type, const char *message) Report *report; int len; - /* exception, print and return in background, no reason to store a list */ - if(G.background) - reports= NULL; - - if(!reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) { + /* in background mode always print otherwise there are cases the errors wont be displayed, + * but still add to the report list since this is used for python exception handling */ + if(G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) { printf("%s: %s\n", report_type_str(type), message); fflush(stdout); /* this ensures the message is printed before a crash */ } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index e38f1bb545c..3ba18fee615 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -4151,7 +4151,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i else if(cache_result==PTCACHE_READ_OLD) { ; /* do nothing */ } - else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) { + else if(/*ob->id.lib || */(cache->flag & PTCACHE_BAKED)) { /* "library linking & pointcaches" has to be solved properly at some point */ /* if baked and nothing in cache, do nothing */ BKE_ptcache_invalidate(cache); return; diff --git a/source/blender/blenlib/BLI_bpath.h b/source/blender/blenlib/BLI_bpath.h index ff0050649ed..8c351d6020d 100644 --- a/source/blender/blenlib/BLI_bpath.h +++ b/source/blender/blenlib/BLI_bpath.h @@ -36,7 +36,7 @@ struct BPathIterator; struct ReportList; struct Main; -void BLI_bpathIterator_init (struct BPathIterator **bpi, struct Main *bmain, const char *basedir); +void BLI_bpathIterator_init (struct BPathIterator **bpi, struct Main *bmain, const char *basedir, const int flag); void BLI_bpathIterator_free (struct BPathIterator *bpi); const char* BLI_bpathIterator_getLib (struct BPathIterator *bpi); const char* BLI_bpathIterator_getName (struct BPathIterator *bpi); @@ -57,4 +57,6 @@ void makeFilesRelative(struct Main *bmain, const char *basedir, struct ReportLis void makeFilesAbsolute(struct Main *bmain, const char *basedir, struct ReportList *reports); void findMissingFiles(struct Main *bmain, const char *str); +#define BPATH_USE_PACKED 1 + #endif // BLI_BPATH_H diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index 7e93765ca72..b20a42f5cf8 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -155,7 +155,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) int box_index, verts_pack_len, i, j, k, isect; int quad_flags[4]= {BLF,TRF,TLF,BRF}; /* use for looping */ boxPack *box, *box_test; /*current box and another for intersection tests*/ - int *vertex_pack_indicies; /*an array of indices used for sorting verts*/ + int *vertex_pack_indices; /*an array of indices used for sorting verts*/ if (!len) { *tot_width = 0.0f; @@ -168,7 +168,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) /* add verts to the boxes, these are only used internally */ vert = vertarray = MEM_mallocN( len*4*sizeof(boxVert), "boxPack Verts"); - vertex_pack_indicies = MEM_mallocN( len*3*sizeof(int), "boxPack Indices"); + vertex_pack_indices = MEM_mallocN( len*3*sizeof(int), "boxPack Indices"); for (box=boxarray, box_index=0, i=0; box_index < len; box_index++, box++) { @@ -225,7 +225,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) box->x = box->y = 0.0f; for (i=0; i<3; i++) - vertex_pack_indicies[i] = box->v[i+1]->index; + vertex_pack_indices[i] = box->v[i+1]->index; verts_pack_len = 3; box++; /* next box, needed for the loop below */ /* ...done packing the first box */ @@ -237,14 +237,14 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) box_width = box->w; box_height = box->h; - qsort(vertex_pack_indicies, verts_pack_len, sizeof(int), vertex_sort); + qsort(vertex_pack_indices, verts_pack_len, sizeof(int), vertex_sort); /* Pack the box in with the others */ /* sort the verts */ isect = 1; for (i=0; i<verts_pack_len && isect; i++) { - vert = vertarray + vertex_pack_indicies[i]; + vert = vertarray + vertex_pack_indices[i]; /* printf("\ttesting vert %i %i %i %f %f\n", i, * vert->free, verts_pack_len, vert->x, vert->y); */ @@ -401,7 +401,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) for (k=0; k<4; k++) { if (box->v[k] != vert) { - vertex_pack_indicies[verts_pack_len] = + vertex_pack_indices[verts_pack_len] = box->v[k]->index; verts_pack_len++; } @@ -423,7 +423,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) box = boxarray+box_index; box->v[0] = box->v[1] = box->v[2] = box->v[3] = NULL; } - MEM_freeN(vertex_pack_indicies); + MEM_freeN(vertex_pack_indices); MEM_freeN(vertarray); } diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 92deb6fbebc..c930bd903b4 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -91,6 +91,7 @@ typedef struct BPathIterator { void* data; int len; int type; + int flag; /* iterator options */ void (*setpath_callback)(struct BPathIterator *, const char *); void (*getpath_callback)(struct BPathIterator *, char *); @@ -123,7 +124,8 @@ enum BPathTypes { BPATH_DONE }; -void BLI_bpathIterator_init(struct BPathIterator **bpi_pt, Main *bmain, const char *basedir) { +void BLI_bpathIterator_init(struct BPathIterator **bpi_pt, Main *bmain, const char *basedir, const int flag) +{ BPathIterator *bpi; bpi= MEM_mallocN(sizeof(BPathIterator), "BLI_bpathIterator_init"); @@ -140,7 +142,9 @@ void BLI_bpathIterator_init(struct BPathIterator **bpi_pt, Main *bmain, const ch bpi->seqdata.seq= 0; bpi->seqdata.seqar= NULL; bpi->seqdata.scene= NULL; - + + bpi->flag= flag; + /* Freestyle module specific */ bpi->frsmoduledata.scene= NULL; bpi->frsmoduledata.layer= NULL; @@ -214,7 +218,8 @@ const char* BLI_bpathIterator_getBasePath( struct BPathIterator *bpi) { } /* gets the first or the next image that has a path - not a viewer node or generated image */ -static struct Image *ima_stepdata__internal(struct Image *ima, int step_next) { +static struct Image *ima_stepdata__internal(struct Image *ima, const int step_next, const int flag) +{ if (ima==NULL) return NULL; @@ -222,15 +227,19 @@ static struct Image *ima_stepdata__internal(struct Image *ima, int step_next) { ima= ima->id.next; while (ima) { - if (ima->packedfile==NULL && ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) - break; + if (ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { + if(ima->packedfile==NULL || (flag & BPATH_USE_PACKED)) { + break; + } + } /* image is not a image with a path, skip it */ ima= ima->id.next; } return ima; } -static struct Tex *tex_stepdata__internal(struct Tex *tex, int step_next) { +static struct Tex *tex_stepdata__internal(struct Tex *tex, const int step_next, const int UNUSED(flag)) +{ if (tex==NULL) return NULL; @@ -246,7 +255,8 @@ static struct Tex *tex_stepdata__internal(struct Tex *tex, int step_next) { return tex; } -static struct Text *text_stepdata__internal(struct Text *text, int step_next) { +static struct Text *text_stepdata__internal(struct Text *text, const int step_next, const int UNUSED(flag)) +{ if (text==NULL) return NULL; @@ -262,7 +272,8 @@ static struct Text *text_stepdata__internal(struct Text *text, int step_next) { return text; } -static struct VFont *vf_stepdata__internal(struct VFont *vf, int step_next) { +static struct VFont *vf_stepdata__internal(struct VFont *vf, const int step_next, const int flag) +{ if (vf==NULL) return NULL; @@ -270,8 +281,10 @@ static struct VFont *vf_stepdata__internal(struct VFont *vf, int step_next) { vf= vf->id.next; while (vf) { - if (vf->packedfile==NULL && strcmp(vf->name, FO_BUILTIN_NAME)!=0) { - break; + if (strcmp(vf->name, FO_BUILTIN_NAME)!=0) { + if(vf->packedfile==NULL || (flag & BPATH_USE_PACKED)) { + break; + } } /* font with no path, skip it */ @@ -280,7 +293,8 @@ static struct VFont *vf_stepdata__internal(struct VFont *vf, int step_next) { return vf; } -static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next) { +static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next, const int flag) +{ if (snd==NULL) return NULL; @@ -288,10 +302,10 @@ static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next) snd= snd->id.next; while (snd) { - if (snd->packedfile==NULL) { + if(snd->packedfile==NULL || (flag & BPATH_USE_PACKED)) { break; } - + /* font with no path, skip it */ snd= snd->id.next; } @@ -486,8 +500,8 @@ void BLI_bpathIterator_step( struct BPathIterator *bpi) { if ((bpi->type) == BPATH_IMAGE) { /*if (bpi->data) bpi->data= ((ID *)bpi->data)->next;*/ - if (bpi->data) bpi->data= ima_stepdata__internal( (Image *)bpi->data, 1 ); /* must skip images that have no path */ - else bpi->data= ima_stepdata__internal(bpi->bmain->image.first, 0); + if (bpi->data) bpi->data= ima_stepdata__internal((Image *)bpi->data, 1, bpi->flag); /* must skip images that have no path */ + else bpi->data= ima_stepdata__internal(bpi->bmain->image.first, 0, bpi->flag); if (bpi->data) { /* get the path info from this datatype */ @@ -508,8 +522,8 @@ void BLI_bpathIterator_step( struct BPathIterator *bpi) { if ((bpi->type) == BPATH_TEXTURE) { /*if (bpi->data) bpi->data= ((ID *)bpi->data)->next;*/ - if (bpi->data) bpi->data= tex_stepdata__internal( (Tex *)bpi->data, 1 ); /* must skip images that have no path */ - else bpi->data= tex_stepdata__internal(bpi->bmain->tex.first, 0); + if (bpi->data) bpi->data= tex_stepdata__internal( (Tex *)bpi->data, 1, bpi->flag); /* must skip images that have no path */ + else bpi->data= tex_stepdata__internal(bpi->bmain->tex.first, 0, bpi->flag); if (bpi->data) { /* get the path info from this datatype */ @@ -535,8 +549,8 @@ void BLI_bpathIterator_step( struct BPathIterator *bpi) { if ((bpi->type) == BPATH_TEXT) { /*if (bpi->data) bpi->data= ((ID *)bpi->data)->next;*/ - if (bpi->data) bpi->data= text_stepdata__internal( (Text *)bpi->data, 1 ); /* must skip images that have no path */ - else bpi->data= text_stepdata__internal(bpi->bmain->text.first, 0); + if (bpi->data) bpi->data= text_stepdata__internal((Text *)bpi->data, 1, bpi->flag); /* must skip images that have no path */ + else bpi->data= text_stepdata__internal(bpi->bmain->text.first, 0, bpi->flag); if (bpi->data) { /* get the path info from this datatype */ @@ -556,8 +570,8 @@ void BLI_bpathIterator_step( struct BPathIterator *bpi) { } else if ((bpi->type) == BPATH_SOUND) { - if (bpi->data) bpi->data= snd_stepdata__internal( (bSound *)bpi->data, 1 ); /* must skip images that have no path */ - else bpi->data= snd_stepdata__internal(bpi->bmain->sound.first, 0); + if (bpi->data) bpi->data= snd_stepdata__internal((bSound *)bpi->data, 1, bpi->flag); /* must skip images that have no path */ + else bpi->data= snd_stepdata__internal(bpi->bmain->sound.first, 0, bpi->flag); if (bpi->data) { /* get the path info from this datatype */ @@ -577,8 +591,8 @@ void BLI_bpathIterator_step( struct BPathIterator *bpi) { } else if ((bpi->type) == BPATH_FONT) { - if (bpi->data) bpi->data= vf_stepdata__internal( (VFont *)bpi->data, 1 ); - else bpi->data= vf_stepdata__internal( bpi->bmain->vfont.first, 0 ); + if (bpi->data) bpi->data= vf_stepdata__internal((VFont *)bpi->data, 1, bpi->flag); + else bpi->data= vf_stepdata__internal(bpi->bmain->vfont.first, 0, bpi->flag); if (bpi->data) { /* get the path info from this datatype */ @@ -721,7 +735,7 @@ void checkMissingFiles(Main *bmain, ReportList *reports) { /* be sure there is low chance of the path being too short */ char filepath_expanded[FILE_MAXDIR*2]; - BLI_bpathIterator_init(&bpi, bmain, bmain->name); + BLI_bpathIterator_init(&bpi, bmain, bmain->name, 0); while (!BLI_bpathIterator_isDone(bpi)) { BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded); @@ -743,7 +757,7 @@ void makeFilesRelative(Main *bmain, const char *basedir, ReportList *reports) { /* be sure there is low chance of the path being too short */ char filepath_relative[(FILE_MAXDIR * 2) + FILE_MAXFILE]; - BLI_bpathIterator_init(&bpi, bmain, basedir); + BLI_bpathIterator_init(&bpi, bmain, basedir, 0); while (!BLI_bpathIterator_isDone(bpi)) { BLI_bpathIterator_getPath(bpi, filepath); libpath= BLI_bpathIterator_getLib(bpi); @@ -794,7 +808,7 @@ void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports) /* be sure there is low chance of the path being too short */ char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE]; - BLI_bpathIterator_init(&bpi, bmain, basedir); + BLI_bpathIterator_init(&bpi, bmain, basedir, 0); while (!BLI_bpathIterator_isDone(bpi)) { BLI_bpathIterator_getPath(bpi, filepath); libpath= BLI_bpathIterator_getLib(bpi); @@ -900,7 +914,7 @@ void findMissingFiles(Main *bmain, const char *str) { BLI_split_dirfile(str, dirname, NULL); - BLI_bpathIterator_init(&bpi, bmain, bmain->name); + BLI_bpathIterator_init(&bpi, bmain, bmain->name, 0); while (!BLI_bpathIterator_isDone(bpi)) { BLI_bpathIterator_getPath(bpi, filepath); diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index d25aefef543..15f696e073c 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -236,51 +236,39 @@ float dist_to_line_segment_v3(float *v1, float *v2, float *v3) /* intersect Line-Line, shorts */ int isect_line_line_v2_short(const short *v1, const short *v2, const short *v3, const short *v4) { - /* return: - -1: colliniar - 0: no intersection of segments - 1: exact intersection of segments - 2: cross-intersection of segments - */ float div, labda, mu; div= (float)((v2[0]-v1[0])*(v4[1]-v3[1])-(v2[1]-v1[1])*(v4[0]-v3[0])); - if(div==0.0f) return -1; + if(div==0.0f) return ISECT_LINE_LINE_COLINEAR; labda= ((float)(v1[1]-v3[1])*(v4[0]-v3[0])-(v1[0]-v3[0])*(v4[1]-v3[1]))/div; mu= ((float)(v1[1]-v3[1])*(v2[0]-v1[0])-(v1[0]-v3[0])*(v2[1]-v1[1]))/div; if(labda>=0.0f && labda<=1.0f && mu>=0.0f && mu<=1.0f) { - if(labda==0.0f || labda==1.0f || mu==0.0f || mu==1.0f) return 1; - return 2; + if(labda==0.0f || labda==1.0f || mu==0.0f || mu==1.0f) return ISECT_LINE_LINE_EXACT; + return ISECT_LINE_LINE_CROSS; } - return 0; + return ISECT_LINE_LINE_NONE; } /* intersect Line-Line, floats */ int isect_line_line_v2(const float *v1, const float *v2, const float *v3, const float *v4) { - /* return: - -1: colliniar -0: no intersection of segments -1: exact intersection of segments -2: cross-intersection of segments - */ float div, labda, mu; div= (v2[0]-v1[0])*(v4[1]-v3[1])-(v2[1]-v1[1])*(v4[0]-v3[0]); - if(div==0.0) return -1; + if(div==0.0) return ISECT_LINE_LINE_COLINEAR; labda= ((float)(v1[1]-v3[1])*(v4[0]-v3[0])-(v1[0]-v3[0])*(v4[1]-v3[1]))/div; mu= ((float)(v1[1]-v3[1])*(v2[0]-v1[0])-(v1[0]-v3[0])*(v2[1]-v1[1]))/div; if(labda>=0.0 && labda<=1.0 && mu>=0.0 && mu<=1.0) { - if(labda==0.0 || labda==1.0 || mu==0.0 || mu==1.0) return 1; - return 2; + if(labda==0.0 || labda==1.0 || mu==0.0 || mu==1.0) return ISECT_LINE_LINE_EXACT; + return ISECT_LINE_LINE_CROSS; } - return 0; + return ISECT_LINE_LINE_NONE; } /* get intersection point of two 2D segments and return intersection type: diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 60b56df1258..a5077af5647 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2105,8 +2105,11 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) else if(ELEM3(node->type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) ((ImageUser *)node->storage)->ok= 1; } - else if( ntree->type==NTREE_TEXTURE && (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) ) { - direct_link_curvemapping(fd, node->storage); + else if( ntree->type==NTREE_TEXTURE) { + if(node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) + direct_link_curvemapping(fd, node->storage); + else if(node->type==TEX_NODE_IMAGE) + ((ImageUser *)node->storage)->ok= 1; } } link_list(fd, &node->inputs); @@ -3821,11 +3824,11 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) clmd->sim_parms->reset = 0; clmd->sim_parms->effector_weights = newdataadr(fd, clmd->sim_parms->effector_weights); - } - if(!clmd->sim_parms->effector_weights) - clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL); - + if(!clmd->sim_parms->effector_weights) { + clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL); + } + } } else if (md->type==eModifierType_Fluidsim) { FluidsimModifierData *fluidmd = (FluidsimModifierData*) md; @@ -9014,9 +9017,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ob->soft->pointcache= BKE_ptcache_add(&ob->soft->ptcaches); for(psys=ob->particlesystem.first; psys; psys=psys->next) { - //if(psys->soft && !psys->soft->pointcache) - // psys->soft->pointcache= BKE_ptcache_add(&psys->soft->ptcaches); - if(!psys->pointcache) + if(psys->pointcache) { + if(psys->pointcache->flag & PTCACHE_BAKED && (psys->pointcache->flag & PTCACHE_DISK_CACHE)==0) { + printf("Old memory cache isn't supported for particles, so re-bake the simulation!\n"); + psys->pointcache->flag &= ~PTCACHE_BAKED; + } + } + else psys->pointcache= BKE_ptcache_add(&psys->ptcaches); } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 1b2c44cfb31..ba275ae7f48 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1963,21 +1963,23 @@ static void write_gpencils(WriteData *wd, ListBase *lb) bGPDstroke *gps; for (gpd= lb->first; gpd; gpd= gpd->id.next) { - /* write gpd data block to file */ - writestruct(wd, ID_GD, "bGPdata", 1, gpd); - - /* write grease-pencil layers to file */ - for (gpl= gpd->layers.first; gpl; gpl= gpl->next) { - writestruct(wd, DATA, "bGPDlayer", 1, gpl); + if (gpd->id.us>0 || wd->current) { + /* write gpd data block to file */ + writestruct(wd, ID_GD, "bGPdata", 1, gpd); - /* write this layer's frames to file */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { - writestruct(wd, DATA, "bGPDframe", 1, gpf); + /* write grease-pencil layers to file */ + for (gpl= gpd->layers.first; gpl; gpl= gpl->next) { + writestruct(wd, DATA, "bGPDlayer", 1, gpl); - /* write strokes */ - for (gps= gpf->strokes.first; gps; gps= gps->next) { - writestruct(wd, DATA, "bGPDstroke", 1, gps); - writestruct(wd, DATA, "bGPDspoint", gps->totpoints, gps->points); + /* write this layer's frames to file */ + for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + writestruct(wd, DATA, "bGPDframe", 1, gpf); + + /* write strokes */ + for (gps= gpf->strokes.first; gps; gps= gps->next) { + writestruct(wd, DATA, "bGPDstroke", 1, gps); + writestruct(wd, DATA, "bGPDspoint", gps->totpoints, gps->points); + } } } } @@ -2525,6 +2527,10 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) bScreen *screen; char subvstr[8]; + /* prevent mem checkers from complaining */ + fg.pads= fg.pad= 0; + memset(fg.filename, 0, sizeof(fg.filename)); + current_screen_compat(mainvar, &screen); /* XXX still remap G */ @@ -2550,7 +2556,6 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) #else fg.revision= 0; #endif - fg.pads= fg.pad= 0; /* prevent mem checkers from complaining */ writestruct(wd, GLOB, "FileGlobal", 1, &fg); } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 888ab9769d8..b779250995e 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -95,7 +95,7 @@ short ANIM_get_keyframing_flags (Scene *scene, short incl_mode) if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED; - /* default F-Curve color mode - RGB from XYZ indicies */ + /* default F-Curve color mode - RGB from XYZ indices */ if (IS_AUTOKEY_FLAG(XYZ2RGB)) flag |= INSERTKEY_XYZ2RGB; } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 51b00cc0086..24bd5b3ec5e 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -500,7 +500,7 @@ void ANIM_OT_keying_set_active_set (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* keyingset to use - * - here the type is int not enum, since many of the indicies here are determined dynamically + * - here the type is int not enum, since many of the indices here are determined dynamically */ RNA_def_int(ot->srna, "type", 0, INT_MIN, INT_MAX, "Keying Set Number", "Index (determined internally) of the Keying Set to use", 0, 1); } diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 2252c926c71..e0172b603b7 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -3000,14 +3000,13 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) bArmature *arm= (obedit) ? obedit->data : NULL; Scene *scene= CTX_data_scene(C); View3D *v3d= CTX_wm_view3d(C); - EditBone *newbone=NULL; ListBase points = {NULL, NULL}; int count; - + /* sanity checks */ - if ELEM(NULL, obedit, arm) + if (ELEM(NULL, obedit, arm)) return OPERATOR_CANCELLED; - + /* loop over all bones, and only consider if visible */ CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones) { @@ -3041,7 +3040,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d)); /* Create a bone */ - newbone= add_points_bone(obedit, ebp->vec, curs); + /* newbone= */ add_points_bone(obedit, ebp->vec, curs); } else if (count == 2) { EditBonePoint *ebp, *ebp2; @@ -3102,7 +3101,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) /* add new bone and parent it to the appropriate end */ if (headtail) { - newbone= add_points_bone(obedit, head, tail); + EditBone *newbone= add_points_bone(obedit, head, tail); /* do parenting (will need to set connected flag too) */ if (headtail == 2) { diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index ce4a61b5cff..3eaf53b4bcb 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -2184,7 +2184,7 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) /* use for smoothing */ int last_sel; - int start_sel, end_sel; /* selection indicies, inclusive */ + int start_sel, end_sel; /* selection indices, inclusive */ float start_rad, end_rad, fac, range; for(nu= editnurb->first; nu; nu= nu->next) { @@ -6096,21 +6096,18 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) Curve *cu= (Curve*)obedit->data; float vec[3], zvec[3]= {0.0f, 0.0f, 1.0f}; float umat[4][4]= MAT4_UNITY, viewmat[4][4]= MAT4_UNITY; - float fac, grid; - int a, b, cutype, stype; - int force_3d = ((Curve *)obedit->data)->flag & CU_3D; /* could be adding to an existing 3D curve */ + float fac; + int a, b; + const float grid= v3d ? v3d->grid : 1.0f; + const int cutype= (type & CU_TYPE); // poly, bezier, nurbs, etc + const int stype= (type & CU_PRIMITIVE); + const int force_3d = ((Curve *)obedit->data)->flag & CU_3D; /* could be adding to an existing 3D curve */ if(rv3d) { copy_m4_m4(viewmat, rv3d->viewmat); VECCOPY(zvec, rv3d->viewinv[2]); } - - cutype= type & CU_TYPE; // poly, bezier, nurbs, etc - stype= type & CU_PRIMITIVE; - - if (v3d) grid = v3d->grid; - else grid = 1.0; - + setflagsNurb(editnurb, 0); /* these types call this function to return a Nurb */ @@ -6432,6 +6429,10 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) } break; + + default: /* should never happen */ + BLI_assert(!"invalid nurbs type"); + return NULL; } /* always do: */ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 3a82274e356..baa6f7d6a25 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -45,6 +45,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_gpencil_types.h" +#include "DNA_windowmanager_types.h" #include "UI_view2d.h" @@ -66,6 +67,8 @@ /* Temporary 'Stroke' Operation data */ typedef struct tGPsdata { Scene *scene; /* current scene from context */ + + wmWindow *win; /* window where painting originated */ ScrArea *sa; /* area where painting originated */ ARegion *ar; /* region where painting originated */ View2D *v2d; /* needed for GP_STROKE_2DSPACE */ @@ -888,15 +891,16 @@ static tGPsdata *gp_session_initpaint (bContext *C) /* create new context data */ p= MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data"); - /* pass on current scene */ + /* pass on current scene and window */ p->scene= CTX_data_scene(C); + p->win= CTX_wm_window(C); switch (curarea->spacetype) { /* supported views first */ case SPACE_VIEW3D: { - View3D *v3d= curarea->spacedata.first; - RegionView3D *rv3d= ar->regiondata; + // View3D *v3d= curarea->spacedata.first; + // RegionView3D *rv3d= ar->regiondata; /* set current area * - must verify that region data is 3D-view (and not something else) @@ -910,12 +914,6 @@ static tGPsdata *gp_session_initpaint (bContext *C) printf("Error: 3D-View active region doesn't have any region data, so cannot be drawable \n"); return p; } - - /* for camera view set the subrect */ - if(rv3d->persp == RV3D_CAMOB) { - view3d_calc_camera_border(p->scene, p->ar, NULL, v3d, &p->subrect_data, -1); /* negative shift */ - p->subrect= &p->subrect_data; - } #if 0 // XXX will this sort of antiquated stuff be restored? /* check that gpencil data is allowed to be drawn */ @@ -1097,9 +1095,17 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) switch (p->sa->spacetype) { case SPACE_VIEW3D: { + View3D *v3d= p->sa->spacedata.first; RegionView3D *rv3d= p->ar->regiondata; float rvec[3]; + /* for camera view set the subrect */ + if (rv3d->persp == RV3D_CAMOB) { + view3d_calc_camera_border(p->scene, p->ar, NULL, v3d, &p->subrect_data, -1); /* negative shift */ + p->subrect= &p->subrect_data; + } + + /* get reference point for 3d space placement */ gp_get_3d_reference(p, rvec); initgrabz(rv3d, rvec[0], rvec[1], rvec[2]); @@ -1172,6 +1178,17 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) /* finish off a stroke (clears buffer, but doesn't finish the paint operation) */ static void gp_paint_strokeend (tGPsdata *p) { + /* for surface sketching, need to set the right OpenGL context stuff so that + * the conversions will project the values correctly... + */ + if (gpencil_project_check(p)) { + View3D *v3d= p->sa->spacedata.first; + + /* need to restore the original projection settings before packing up */ + view3d_region_operator_needs_opengl(p->win, p->ar); + view_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0); + } + /* check if doing eraser or not */ if ((p->gpd->sbuffer_sflag & GP_STROKE_ERASER) == 0) { /* smooth stroke before transferring? */ @@ -1247,14 +1264,6 @@ static void gpencil_draw_exit (bContext *C, wmOperator *op) } /* cleanup */ - if (gpencil_project_check(p)) { - View3D *v3d= p->sa->spacedata.first; - - /* need to restore the original projection settings before packing up */ - view3d_operator_needs_opengl(C); - view_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0); - } - gp_paint_cleanup(p); gp_session_cleanup(p); @@ -1573,7 +1582,7 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) if (GPENCIL_SKETCH_SESSIONS_ON(p->scene)) { /* end stroke only, and then wait to resume painting soon */ //printf("\t\tGP - end stroke only\n"); - gp_paint_strokeend(p); + gp_paint_cleanup(p); p->status= GP_STATUS_IDLING; /* we've just entered idling state, so this event was processed (but no others yet) */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 337104e3737..d6fc0797449 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -47,6 +47,7 @@ struct RegionView3D; struct Scene; struct View3D; struct ViewContext; +struct wmWindow; /* for derivedmesh drawing callbacks, for view3d_select, .... */ @@ -144,6 +145,7 @@ short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigne void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc); void view3d_operator_needs_opengl(const struct bContext *C); +void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *ar); void view3d_get_view_aligned_coordinate(struct ViewContext *vc, float *fp, short mval[2]); void view3d_get_transformation(struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob, struct bglMats *mats); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 1ea4f88ebe6..b9ded28b613 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -211,6 +211,7 @@ typedef struct uiLayout uiLayout; #define TOGBUT (37<<9) #define OPTION (38<<9) #define OPTIONN (39<<9) + /* buttons with value >= SEARCH_MENU don't get undo pushes */ #define SEARCH_MENU (40<<9) #define BUT_EXTRA (41<<9) #define HSVCIRCLE (42<<9) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 2620db30b39..43919617047 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -523,6 +523,7 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut #endif but->active= oldbut->active; but->pos= oldbut->pos; + but->ofs= oldbut->ofs; but->editstr= oldbut->editstr; but->editval= oldbut->editval; but->editvec= oldbut->editvec; @@ -2505,8 +2506,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, } } - if(ELEM8(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, SEARCH_MENU, BUTM)); + /* keep track of UI_interface.h */ + if(ELEM7(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM)); else if(ELEM5(but->type, SCROLL, SEPR, LINK, INLINK, FTPREVIEW)); + else if(but->type >= SEARCH_MENU); else but->flag |= UI_BUT_UNDO; BLI_addtail(&block->buttons, but); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index ffb18bcad4d..d49e7866268 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5722,7 +5722,7 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, if(ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) && event->val==KM_PRESS) { if(saferct && !BLI_in_rctf(&saferct->parent, event->x, event->y)) { - if(block->flag & (UI_BLOCK_OUT_1|UI_BLOCK_KEEP_OPEN)) + if(block->flag & (UI_BLOCK_OUT_1)) menu->menuretval= UI_RETURN_OK; else menu->menuretval= UI_RETURN_OUT; @@ -5763,7 +5763,7 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, /* strict check, and include the parent rect */ if(!menu->dotowards && !saferct) { - if(block->flag & (UI_BLOCK_OUT_1|UI_BLOCK_KEEP_OPEN)) + if(block->flag & (UI_BLOCK_OUT_1)) menu->menuretval= UI_RETURN_OK; else menu->menuretval= UI_RETURN_OUT; diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index ff041c18b00..788de41202d 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -48,6 +48,7 @@ #include "DNA_brush_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "RNA_access.h" #include "RNA_enum_types.h" @@ -1000,42 +1001,62 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al } } -void ui_id_icon_render(bContext *C, ID *id, int preview) +static void ui_id_icon_render(bContext *C, ID *id, int big) { PreviewImage *pi = BKE_previewimg_get(id); - + if (pi) { if ((pi->changed[0] ||!pi->rect[0])) /* changed only ever set by dynamic icons */ { - /* create the preview rect if necessary */ + /* create the rect if necessary */ icon_set_image(C, id, pi, 0); /* icon size */ - if (preview) - icon_set_image(C, id, pi, 1); /* preview size */ + if (big) + icon_set_image(C, id, pi, 1); /* bigger preview size */ pi->changed[0] = 0; } } } -static int ui_id_brush_get_icon(bContext *C, ID *id, int preview) +static void ui_id_brush_render(bContext *C, ID *id) +{ + PreviewImage *pi = BKE_previewimg_get(id); + int i; + + if(!pi) + return; + + for(i = 0; i < PREVIEW_MIPMAPS; i++) { + /* check if rect needs to be created; changed + only set by dynamic icons */ + if((pi->changed[i] || !pi->rect[i])) { + icon_set_image(C, id, pi, i); + pi->changed[i] = 0; + } + } +} + + +static int ui_id_brush_get_icon(bContext *C, ID *id) { Brush *br = (Brush*)id; if(br->flag & BRUSH_CUSTOM_ICON) { BKE_icon_getid(id); - ui_id_icon_render(C, id, preview); + ui_id_brush_render(C, id); } else { Object *ob = CTX_data_active_object(C); - EnumPropertyItem *items; + SpaceImage *sima; + EnumPropertyItem *items = NULL; int tool, mode = 0; - /* this is not nice, should probably make brushes be - strictly in one paint mode only to avoid checking - object mode here */ + /* XXX: this is not nice, should probably make brushes + be strictly in one paint mode only to avoid + checking various context stuff here */ - if(ob) { + if(CTX_wm_view3d(C) && ob) { if(ob->mode & OB_MODE_SCULPT) mode = OB_MODE_SCULPT; else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT)) @@ -1043,12 +1064,10 @@ static int ui_id_brush_get_icon(bContext *C, ID *id, int preview) else if(ob->mode & OB_MODE_TEXTURE_PAINT) mode = OB_MODE_TEXTURE_PAINT; } - - /* check if cached icon is OK */ - if(!mode || (id->icon_id && mode == br->icon_mode)) - return id->icon_id; - - br->icon_mode = mode; + else if((sima = CTX_wm_space_image(C)) && + (sima->flag & SI_DRAWTOOL)) { + mode = OB_MODE_TEXTURE_PAINT; + } /* reset the icon */ if(mode == OB_MODE_SCULPT) { @@ -1064,14 +1083,14 @@ static int ui_id_brush_get_icon(bContext *C, ID *id, int preview) tool = br->imagepaint_tool; } - if(!RNA_enum_icon_from_value(items, tool, &id->icon_id)) + if(!items || !RNA_enum_icon_from_value(items, tool, &id->icon_id)) id->icon_id = 0; } return id->icon_id; } -int ui_id_icon_get(bContext *C, ID *id, int preview) +int ui_id_icon_get(bContext *C, ID *id, int big) { int iconid= 0; @@ -1079,7 +1098,7 @@ int ui_id_icon_get(bContext *C, ID *id, int preview) switch(GS(id->name)) { case ID_BR: - iconid= ui_id_brush_get_icon(C, id, preview); + iconid= ui_id_brush_get_icon(C, id); break; case ID_MA: /* fall through */ case ID_TE: /* fall through */ @@ -1088,7 +1107,7 @@ int ui_id_icon_get(bContext *C, ID *id, int preview) case ID_LA: /* fall through */ iconid= BKE_icon_getid(id); /* checks if not exists, or changed */ - ui_id_icon_render(C, id, preview); + ui_id_icon_render(C, id, big); break; default: break; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 95b808fe4b1..7dde0a73d56 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -479,7 +479,6 @@ void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, char *name, in void uiStyleInit(void); /* interface_icons.c */ -void ui_id_icon_render(struct bContext *C, struct ID *id, int preview); int ui_id_icon_get(struct bContext *C, struct ID *id, int preview); /* resources.c */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index f39a0204dcb..d67946752da 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1234,7 +1234,7 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN but->hardmax= MAX2(but->hardmax, 256); but->rnasearchpoin= *searchptr; but->rnasearchprop= searchprop; - but->flag |= UI_ICON_LEFT|UI_TEXT_LEFT|UI_BUT_UNDO; + but->flag |= UI_ICON_LEFT|UI_TEXT_LEFT; uiButSetSearchFunc(but, rna_search_cb, but, NULL, NULL); } @@ -2730,4 +2730,12 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in uiItemL(layout, "No Properties.", ICON_NULL); } } + + /* no undo for buttons for operator redo panels */ + { + uiBut *but; + + for(but= uiLayoutGetBlock(layout)->buttons.first; but; but= but->next) + uiButClearFlag(but, UI_BUT_UNDO); + } } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 571a48a4100..4b855b88ece 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1984,7 +1984,7 @@ uiBlock *ui_block_func_COL(bContext *C, uiPopupBlockHandle *handle, void *arg_bu uiBlockPicker(block, handle->retvec, &but->rnapoin, but->rnaprop); - block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_KEEP_OPEN; + block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_KEEP_OPEN|UI_BLOCK_OUT_1; uiBoundsBlock(block, 10); block->block_event_func= ui_picker_small_wheel_cb; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index cf29794434e..4224b0b080f 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -746,7 +746,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) #define PREVIEW_PAD 4 -static void widget_draw_preview(BIFIconID icon, float aspect, float UNUSED(alpha), rcti *rect) +static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect) { int w, h, size; @@ -762,7 +762,7 @@ static void widget_draw_preview(BIFIconID icon, float aspect, float UNUSED(alpha int x = rect->xmin + w/2 - size/2; int y = rect->ymin + h/2 - size/2; - UI_icon_draw_preview_aspect_size(x, y, icon, aspect, size); + UI_icon_draw_preview_aspect_size(x, y, icon, 1.0f, size); } } @@ -776,7 +776,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect float aspect, height; if (but->flag & UI_ICON_PREVIEW) { - widget_draw_preview(icon, but->block->aspect, alpha, rect); + widget_draw_preview(icon, alpha, rect); return; } @@ -871,28 +871,42 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) if (fstyle->kerning==1) /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); - but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr); - but->ofs= 0; + /* if text editing we define ofs dynamically */ + if(but->editstr && but->pos >= 0) { + if(but->ofs > but->pos) + but->ofs= but->pos; + } + else but->ofs= 0; - while(but->strwidth > okwidth ) { - - but->ofs++; - but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs); + but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); + + while(but->strwidth > okwidth) { - /* textbut exception */ - if(but->editstr && but->pos != -1) { - int pos= but->pos+1; + /* textbut exception, clip right when... */ + if(but->editstr && but->pos >= 0) { + float width; + char buf[256]; - if(pos-1 < but->ofs) { - pos= but->ofs-pos+1; - but->ofs -= pos; - if(but->ofs<0) { - but->ofs= 0; - pos--; - } - but->drawstr[ strlen(but->drawstr)-pos ]= 0; + /* copy draw string */ + BLI_strncpy(buf, but->drawstr, sizeof(buf)); + /* string position of cursor */ + buf[but->pos]= 0; + width= BLF_width(fstyle->uifont_id, buf+but->ofs); + + /* if cursor is at 20 pixels of right side button we clip left */ + if(width > okwidth-20) + but->ofs++; + else { + /* shift string to the left */ + if(width < 20 && but->ofs > 0) + but->ofs--; + but->drawstr[ strlen(but->drawstr)-1 ]= 0; } } + else + but->ofs++; + + but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs); if(but->strwidth < 10) break; } @@ -3118,7 +3132,7 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, char *name, int iconi wt->state(wt, state); wt->draw(&wt->wcol, rect, 0, 0); - widget_draw_preview(iconid, 1.f, 1.f, rect); + widget_draw_preview(iconid, 1.0f, rect); if (state == UI_ACTIVE) glColor3ubv((unsigned char*)wt->wcol.text); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 5e3a0c6022a..3a29419074b 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1015,7 +1015,7 @@ void init_userdef_do_versions(void) } if (U.savetime <= 0) { U.savetime = 1; -// XXX error("startup.blend is buggy, please consider removing it.\n"); +// XXX error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n"); } /* transform widget settings */ if(U.tw_hotspot==0) { diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index 8fab314e989..72c0e7a9a64 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -2442,7 +2442,7 @@ void EM_make_hq_normals(EditMesh *em) for(edge_iter = BLI_edgehashIterator_new(edge_hash); !BLI_edgehashIterator_isDone(edge_iter); BLI_edgehashIterator_step(edge_iter)) { - /* Get the edge vert indicies, and edge value (the face indicies that use it)*/ + /* Get the edge vert indices, and edge value (the face indices that use it)*/ BLI_edgehashIterator_getKey(edge_iter, (int*)&ed_v1, (int*)&ed_v2); edge_ref = BLI_edgehashIterator_getValue(edge_iter); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index cd2b0f79f1a..eee17bc78ef 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -491,7 +491,7 @@ void OBJECT_OT_camera_add(wmOperatorType *ot) static int object_metaball_add_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - MetaElem *elem; + /*MetaElem *elem;*/ /*UNUSED*/ int newob= 0; int enter_editmode; unsigned int layer; @@ -511,7 +511,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); - elem= (MetaElem*)add_metaball_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob); + /* elem= (MetaElem *) */ add_metaball_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob); /* userdef */ if (newob && !enter_editmode) { diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 9322886266a..344c2c13861 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -469,11 +469,11 @@ static EnumPropertyItem constraint_owner_items[] = { static int edit_constraint_poll_generic(bContext *C, StructRNA *rna_type) { PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", rna_type); - Object *ob= (ptr.id.data)?ptr.id.data:ED_object_active_context(C); - + Object *ob= (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); + if (!ob || ob->id.lib) return 0; - if (ptr.data && ((ID*)ptr.id.data)->lib) return 0; - + if (ptr.id.data && ((ID*)ptr.id.data)->lib) return 0; + return 1; } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index a0d8e3c9733..704efb59d3d 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1050,7 +1050,8 @@ static unsigned int move_to_layer_init(bContext *C, wmOperator *op) unsigned int lay= 0; if(!RNA_property_is_set(op->ptr, "layers")) { - CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { + /* note: layers are set in bases, library objects work for this */ + CTX_DATA_BEGIN(C, Base*, base, selected_bases) { lay |= base->lay; } CTX_DATA_END; @@ -1098,8 +1099,8 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) if(v3d && v3d->localvd) { /* now we can move out of localview. */ - // XXX if (!okee("Move from localview")) return; - CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { + /* note: layers are set in bases, library objects work for this */ + CTX_DATA_BEGIN(C, Base*, base, selected_bases) { lay= base->lay & ~v3d->lay; base->lay= lay; base->object->lay= lay; @@ -1111,7 +1112,8 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) } else { /* normal non localview operation */ - CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { + /* note: layers are set in bases, library objects work for this */ + CTX_DATA_BEGIN(C, Base*, base, selected_bases) { /* upper byte is used for local view */ local= base->lay & 0xFF000000; base->lay= lay + local; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 8501ee22031..bd7983004eb 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -30,6 +30,7 @@ #include <string.h> #include <stddef.h> #include <math.h> +#include <assert.h> #include "MEM_guardedalloc.h" @@ -168,8 +169,7 @@ int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_tot) return 0; } - i = 0; - for (eve=em->verts.first; eve; eve=eve->next) i++; + i= BLI_countlist(&em->verts); *dvert_arr= MEM_mallocN(sizeof(void*)*i, "vgroup parray from me"); *dvert_tot = i; @@ -492,23 +492,10 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum) /* This routine removes the vertex from the specified * deform group. */ - - int def_nr; - - /* if the object is NULL abort - */ - if(!ob) + const int def_nr= defgroup_find_index(ob, dg); + if(def_nr < 0) return; - /* get the deform number that cooresponds - * to this deform group, and abort if it - * can not be found. - */ - def_nr = defgroup_find_index(ob, dg); - if(def_nr < 0) return; - - /* call another routine to do the work - */ ED_vgroup_nr_vert_remove(ob, def_nr, vertnum); } @@ -1128,55 +1115,52 @@ static void vgroup_delete_update_users(Object *ob, int id) static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg) { - MDeformVert *dvert, *dvert_array=NULL; + MDeformVert *dvert_array=NULL; int i, e, dvert_tot=0; + const int dg_index= BLI_findindex(&ob->defbase, dg); + + assert(dg_index > -1); ED_vgroup_give_array(ob->data, &dvert_array, &dvert_tot); if(dvert_array) { - for(i = 0; i < dvert_tot; i++) { - dvert = dvert_array + i; - if(dvert) { - if(defvert_find_index(dvert, (ob->actdef-1))) - ED_vgroup_vert_remove(ob, dg, i); - } + MDeformVert *dvert; + for(i= 0, dvert= dvert_array; i < dvert_tot; i++, dvert++) { + ED_vgroup_vert_remove(ob, dg, i); /* ok if the dg isnt in this dvert, will continue silently */ } - for(i = 0; i < dvert_tot; i++) { - dvert = dvert_array+i; - if(dvert) { - for(e = 0; e < dvert->totweight; e++) { - if(dvert->dw[e].def_nr > (ob->actdef-1)) - dvert->dw[e].def_nr--; + for(i= 0, dvert= dvert_array; i < dvert_tot; i++, dvert++) { + for(e = 0; e < dvert->totweight; e++) { + if(dvert->dw[e].def_nr > dg_index) { + dvert->dw[e].def_nr--; } } } } - vgroup_delete_update_users(ob, ob->actdef); + vgroup_delete_update_users(ob, dg_index + 1); - /* Update the active deform index if necessary */ - if(ob->actdef == BLI_countlist(&ob->defbase)) - ob->actdef--; - /* Remove the group */ BLI_freelinkN(&ob->defbase, dg); + + /* Update the active deform index if necessary */ + if(ob->actdef > dg_index) + ob->actdef--; + if(ob->actdef < 1 && ob->defbase.first) + ob->actdef= 1; + } /* only in editmode */ /* removes from active defgroup, if allverts==0 only selected vertices */ -static void vgroup_active_remove_verts(Object *ob, int allverts) +static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGroup *dg) { EditVert *eve; MDeformVert *dvert; MDeformWeight *newdw; - bDeformGroup *dg, *eg; + bDeformGroup *eg; int i; - dg=BLI_findlink(&ob->defbase, ob->actdef-1); - if(!dg) - return; - if(ob->type == OB_MESH) { Mesh *me= ob->data; EditMesh *em = BKE_mesh_get_editmesh(me); @@ -1226,15 +1210,15 @@ static void vgroup_active_remove_verts(Object *ob, int allverts) } } -static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *defgroup) +static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg) { int i; + const int dg_index= BLI_findindex(&ob->defbase, dg); - if(!ob->actdef) - return; + assert(dg_index > -1); /* Make sure that no verts are using this group */ - vgroup_active_remove_verts(ob, 1); + vgroup_active_remove_verts(ob, TRUE, dg); /* Make sure that any verts with higher indices are adjusted accordingly */ if(ob->type==OB_MESH) { @@ -1248,7 +1232,7 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *defgroup) if(dvert) for(i=0; i<dvert->totweight; i++) - if(dvert->dw[i].def_nr > (ob->actdef-1)) + if(dvert->dw[i].def_nr > dg_index) dvert->dw[i].def_nr--; } BKE_mesh_end_editmesh(me, em); @@ -1263,24 +1247,26 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *defgroup) tot= lt->pntsu*lt->pntsv*lt->pntsw; for(a=0, bp= lt->def; a<tot; a++, bp++, dvert++) { for(i=0; i<dvert->totweight; i++){ - if(dvert->dw[i].def_nr > (ob->actdef-1)) + if(dvert->dw[i].def_nr > dg_index) dvert->dw[i].def_nr--; } } } } - vgroup_delete_update_users(ob, ob->actdef); + vgroup_delete_update_users(ob, dg_index + 1); + + /* Remove the group */ + BLI_freelinkN (&ob->defbase, dg); /* Update the active deform index if necessary */ - if(ob->actdef==BLI_countlist(&ob->defbase)) + if(ob->actdef > dg_index) ob->actdef--; - - /* Remove the group */ - BLI_freelinkN (&ob->defbase, defgroup); - + if(ob->actdef < 1 && ob->defbase.first) + ob->actdef= 1; + /* remove all dverts */ - if(ob->actdef==0) { + if(ob->defbase.first == NULL) { if(ob->type==OB_MESH) { Mesh *me= ob->data; CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert); @@ -1417,22 +1403,14 @@ static void vgroup_assign_verts(Object *ob, float weight) /* removes from all defgroup, if allverts==0 only selected vertices */ static void vgroup_remove_verts(Object *ob, int allverts) { - int actdef, defCount; - - actdef= ob->actdef; - defCount= BLI_countlist(&ob->defbase); - - if(defCount == 0) - return; - /* To prevent code redundancy, we just use vgroup_active_remove_verts, but that * only operates on the active vgroup. So we iterate through all groups, by changing * active group index */ - for(ob->actdef= 1; ob->actdef <= defCount; ob->actdef++) - vgroup_active_remove_verts(ob, allverts); - - ob->actdef= actdef; + bDeformGroup *dg; + for(dg= ob->defbase.first; dg; dg= dg->next) { + vgroup_active_remove_verts(ob, allverts, dg); + } } /********************** vertex group operators *********************/ @@ -1552,8 +1530,15 @@ static int vertex_group_remove_from_exec(bContext *C, wmOperator *op) if(RNA_boolean_get(op->ptr, "all")) vgroup_remove_verts(ob, 0); - else - vgroup_active_remove_verts(ob, 0); + else { + bDeformGroup *dg= BLI_findlink(&ob->defbase, ob->actdef - 1); + + if(dg == NULL) { + return OPERATOR_CANCELLED; + } + + vgroup_active_remove_verts(ob, FALSE, dg); + } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); @@ -1938,7 +1923,7 @@ void OBJECT_OT_vertex_group_copy_to_selected(wmOperatorType *ot) /* identifiers */ ot->name= "Copy Vertex Group to Selected"; ot->idname= "OBJECT_OT_vertex_group_copy_to_selected"; - ot->description= "Copy Vertex Groups to other selected objects with matching indicies"; + ot->description= "Copy Vertex Groups to other selected objects with matching indices"; /* api callbacks */ ot->poll= vertex_group_poll; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 0017fd0130a..93e652023cf 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -4014,6 +4014,9 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, if(cache && cache->flag & PTCACHE_DISK_CACHE) return; + if(psys == NULL && cache->mem_cache.first == NULL) + return; + if(!edit) { totpoint = psys ? psys->totpart : ((PTCacheMem*)cache->mem_cache.first)->totpoint; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 6f4f996d004..ba73c488c46 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -432,7 +432,8 @@ static void image_undo_restore(bContext *C, ListBase *lb) GPU_free_image(ima); /* force OpenGL reload */ if(ibuf->rect_float) - imb_freerectImBuf(ibuf); /* force recreate of char rect */ + ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ + } IMB_freeImBuf(tmpibuf); @@ -935,7 +936,7 @@ static int pixel_bounds_array(float (* uv)[2], rcti *bounds_px, const int ibuf_x #ifndef PROJ_DEBUG_NOSEAMBLEED -/* This function returns 1 if this face has a seam along the 2 face-vert indicies +/* This function returns 1 if this face has a seam along the 2 face-vert indices * 'orig_i1_fidx' and 'orig_i2_fidx' */ static int check_seam(const ProjPaintState *ps, const int orig_face, const int orig_i1_fidx, const int orig_i2_fidx, int *other_face, int *orig_fidx) { @@ -948,7 +949,7 @@ static int check_seam(const ProjPaintState *ps, const int orig_face, const int o const MFace *orig_mf = ps->dm_mface + orig_face; const MTFace *orig_tf = ps->dm_mtface + orig_face; - /* vert indicies from face vert order indicies */ + /* vert indices from face vert order indices */ i1 = (*(&orig_mf->v1 + orig_i1_fidx)); i2 = (*(&orig_mf->v1 + orig_i2_fidx)); @@ -2576,7 +2577,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i } -/* takes floating point screenspace min/max and returns int min/max to be used as indicies for ps->bucketRect, ps->bucketFlags */ +/* takes floating point screenspace min/max and returns int min/max to be used as indices for ps->bucketRect, ps->bucketFlags */ static void project_paint_bucket_bounds(const ProjPaintState *ps, const float min[2], const float max[2], int bucketMin[2], int bucketMax[2]) { /* divide by bucketWidth & bucketHeight so the bounds are offset in bucket grid units */ @@ -4022,7 +4023,7 @@ static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, s { if(ibuf->rect_float) /* TODO - should just update a portion from imapaintpartial! */ - imb_freerectImBuf(ibuf); /* force recreate of char rect */ + ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ if(ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 1ae26421152..365c17d45c0 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -123,10 +123,10 @@ static void deselect_action_keys (bAnimContext *ac, short test, short sel) /* Now set the flags */ for (ale= anim_data.first; ale; ale= ale->next) { - if (ale->type == ANIMTYPE_FCURVE) - ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL); - else if (ale->type == ANIMTYPE_GPLAYER) + if (ale->type == ANIMTYPE_GPLAYER) set_gplayer_frame_selection(ale->data, sel); + else + ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL); } /* Cleanup */ @@ -253,10 +253,10 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short !((ymax < rectf.ymin) || (ymin > rectf.ymax)) ) { /* loop over data selecting */ - if (ale->type == ANIMTYPE_FCURVE) - ANIM_animchannel_keyframes_loop(&ked, ale, ok_cb, select_cb, NULL, filterflag); - else if (ale->type == ANIMTYPE_GPLAYER) + if (ale->type == ANIMTYPE_GPLAYER) borderselect_gplayer_frames(ale->data, rectf.xmin, rectf.xmax, selectmode); + else + ANIM_animchannel_keyframes_loop(&ked, ale, ok_cb, select_cb, NULL, filterflag); } /* set minimum extent to be the maximum of the next channel */ @@ -484,10 +484,10 @@ static void columnselect_action_keys (bAnimContext *ac, short mode) ked.f1= ce->cfra; /* select elements with frame number matching cfraelem */ - if (ale->type == ANIMTYPE_FCURVE) - ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); - else if (ale->type == ANIMTYPE_GPLAYER) + if (ale->type == ANIMTYPE_GPLAYER) select_gpencil_frame(ale->data, ce->cfra, SELECT_ADD); + else + ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } } @@ -865,10 +865,10 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se ked.f1= selx; /* select elements with frame number matching cfra */ - if (ale->type == ANIMTYPE_FCURVE) - ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); - else if (ale->type == ANIMTYPE_GPLAYER) + if (ale->type == ANIMTYPE_GPLAYER) select_gpencil_frame(ale->key_data, selx, select_mode); + else + ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } /* free elements */ diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 98547dbe798..e9e036a65cb 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -302,7 +302,8 @@ static void file_draw_string(int sx, int sy, const char* string, float width, in fs.align = align; BLI_strncpy(fname,string, FILE_MAXFILE); - + file_shorten_string(fname, width+1.0, 0); + /* no text clipping needed, uiStyleFontDraw does it but is a bit too strict (for buttons it works) */ rect.xmin = sx; rect.xmax = sx + ceil(width+4.0f); diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index dc86a56e9f0..e688454464c 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -178,6 +178,7 @@ void GRAPH_OT_previewrange_set (wmOperatorType *ot) /* identifiers */ ot->name= "Auto-Set Preview Range"; ot->idname= "GRAPH_OT_previewrange_set"; + ot->description= "Automatically set Preview Range based on range of keyframes"; /* api callbacks */ ot->exec= graphkeys_previewrange_exec; diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 95c499c263b..42f0f35f4e8 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -204,6 +204,7 @@ void GRAPH_OT_view_togglehandles (wmOperatorType *ot) /* identification */ ot->name= "Show/Hide All Handles"; ot->idname= "GRAPH_OT_handles_view_toggle"; + ot->description= "Toggle whether handles are drawn on all keyframes that need them"; /* callbacks */ ot->exec= view_toggle_handles_exec; diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index e2d58b1df5f..5fd86e2ed9a 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -83,7 +83,7 @@ static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage) NOTE: if float buffer changes, we have to manually remove the rect */ - if(ibuf->rect_float && ibuf->rect==NULL) { + if(ibuf->rect_float && (ibuf->rect==NULL || (ibuf->userflags & IB_RECT_INVALID)) ) { if(color_manage) { if(ima && ima->source == IMA_SRC_VIEWER) ibuf->profile = IB_PROFILE_LINEAR_RGB; @@ -473,13 +473,18 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy) { - float x, y; - double time_current; - - time_current = PIL_check_seconds_timer(); + const double time_current= PIL_check_seconds_timer(); + + const int xmax= ceil(ar->v2d.cur.xmax); + const int ymax= ceil(ar->v2d.cur.ymax); + const int xmin= floor(ar->v2d.cur.xmin); + const int ymin= floor(ar->v2d.cur.ymin); + + int x; - for(x=floor(ar->v2d.cur.xmin); x<ar->v2d.cur.xmax; x += 1.0f) { - for(y=floor(ar->v2d.cur.ymin); y<ar->v2d.cur.ymax; y += 1.0f) { + for(x=xmin; x<xmax; x++) { + int y; + for(y=ymin; y<ymax; y++) { if(ima && (ima->tpageflag & IMA_TILES)) draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy); else diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 3f4c10c8155..cd54a899f35 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1445,7 +1445,10 @@ static void unpack_menu(bContext *C, const char *opname, Image *ima, const char pup= uiPupMenuBegin(C, "Unpack file", ICON_NULL); layout= uiPupMenuLayout(pup); - uiItemEnumO(layout, opname, "Remove Pack", 0, "method", PF_REMOVE); + sprintf(line, "Remove Pack"); + props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + RNA_enum_set(&props_ptr, "method", PF_REMOVE); + RNA_string_set(&props_ptr, "image", ima->id.name+2); if(strcmp(abs_name, local_name)) { switch(checkPackedFile(local_name, pf)) { diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index c8766f5c4c1..ec8f21065f5 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3263,7 +3263,8 @@ static void draw_sensor_armature(uiLayout *layout, PointerRNA *ptr) } row = uiLayoutRow(layout, 1); uiItemR(row, ptr, "test_type", 0, NULL, ICON_NULL); - uiItemR(row, ptr, "value", 0, NULL, ICON_NULL); + if (RNA_enum_get(ptr, "test_type") != SENS_ARM_STATE_CHANGED) + uiItemR(row, ptr, "value", 0, NULL, ICON_NULL); } static void draw_sensor_collision(uiLayout *layout, PointerRNA *ptr, bContext *C) diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index fd3623eec11..7d4db6fd89c 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -342,8 +342,9 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e void NLA_OT_channels_click (wmOperatorType *ot) { /* identifiers */ - ot->name= "Mouse Click on Channels"; + ot->name= "Mouse Click on NLA Channels"; ot->idname= "NLA_OT_channels_click"; + ot->description= "Handle clicks to select NLA channels"; /* api callbacks */ ot->invoke= nlachannels_mouseclick_invoke; diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index d1417d69ae3..b70a6339fed 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -621,8 +621,8 @@ static int nlaedit_duplicate_exec (bContext *C, wmOperator *UNUSED(op)) /* deselect the original and the active flag */ strip->flag &= ~(NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_ACTIVE); - /* auto-name it */ - BKE_nlastrip_validate_name(adt, strip); + /* auto-name newly created strip */ + BKE_nlastrip_validate_name(adt, nstrip); done++; } @@ -650,7 +650,7 @@ static int nlaedit_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED { nlaedit_duplicate_exec(C, op); - RNA_int_set(op->ptr, "mode", TFM_TIME_TRANSLATE); // XXX + RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); return OPERATOR_FINISHED; @@ -1006,6 +1006,164 @@ void NLA_OT_mute_toggle (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/* ******************** Swap Strips Operator ************************** */ +/* Tries to exchange strips within their owner tracks */ + +static int nlaedit_swap_exec (bContext *C, wmOperator *op) +{ + bAnimContext ac; + + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + + /* get a list of the editable tracks being shown in the NLA */ + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + + /* consider each track in turn */ + for (ale= anim_data.first; ale; ale= ale->next) { + NlaTrack *nlt= (NlaTrack *)ale->data; + + NlaStrip *strip, *stripN=NULL; + NlaStrip *sa=NULL, *sb=NULL; + + /* make temporary metastrips so that entire islands of selections can be moved around */ + BKE_nlastrips_make_metas(&nlt->strips, 1); + + /* special case: if there is only 1 island (i.e. temp meta BUT NOT unselected/normal/normal-meta strips) left after this, + * and this island has two strips inside it, then we should be able to just swap these still... + */ + if ((nlt->strips.first == nlt->strips.last) && (nlt->strips.first != NULL)) { + NlaStrip *mstrip = (NlaStrip *)nlt->strips.first; + + if ((mstrip->flag & NLASTRIP_FLAG_TEMP_META) && (BLI_countlist(&mstrip->strips) == 2)) + { + /* remove this temp meta, so that we can see the strips inside */ + BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); + } + } + + /* get two selected strips only (these will be metas due to prev step) to operate on + * - only allow swapping 2, as with more the context becomes unclear + */ + for (strip = nlt->strips.first; strip; strip = stripN) { + stripN = strip->next; + + if (strip->flag & NLASTRIP_FLAG_SELECT) { + /* first or second strip? */ + if (sa == NULL) { + /* store as first */ + sa = strip; + } + else if (sb == NULL) { + /* store as second */ + sb = strip; + } + else { + /* too many selected */ + break; + } + } + } + + if (strip) { + /* too many selected warning */ + BKE_reportf(op->reports, RPT_WARNING, + "Too many clusters of strips selected in NLA Track (%s). Needs exactly 2 to be selected.", + nlt->name); + } + else if (sa == NULL) { + /* no warning as this is just a common case, and it may get annoying when doing multiple tracks */ + } + else if (sb == NULL) { + /* too few selected warning */ + BKE_reportf(op->reports, RPT_WARNING, + "Too few clusters of strips selected in NLA Track (%s). Needs exactly 2 to be selected.", + nlt->name); + } + else { + float nsa[2], nsb[2]; + + /* remove these strips from the track, so that we can test if they can fit in the proposed places */ + BLI_remlink(&nlt->strips, sa); + BLI_remlink(&nlt->strips, sb); + + /* calculate new extents for strips */ + /* a --> b */ + nsa[0] = sb->start; + nsa[1] = sb->start + (sa->end - sa->start); + /* b --> a */ + nsb[0] = sa->start; + nsb[1] = sa->start + (sb->end - sb->start); + + /* check if the track has room for the strips to be swapped */ + if (BKE_nlastrips_has_space(&nlt->strips, nsa[0], nsa[1]) && + BKE_nlastrips_has_space(&nlt->strips, nsb[0], nsb[1])) + { + /* set new extents for strips then */ + sa->start = nsa[0]; + sa->end = nsa[1]; + BKE_nlameta_flush_transforms(sa); + + sb->start = nsb[0]; + sb->end = nsb[1]; + BKE_nlameta_flush_transforms(sb); + } + else { + /* not enough room to swap, so show message */ + if ((sa->flag & NLASTRIP_FLAG_TEMP_META) || (sb->flag & NLASTRIP_FLAG_TEMP_META)) { + BKE_report(op->reports, RPT_WARNING, + "Cannot swap selected strips as they will not be able to fit in their new places"); + } + else { + BKE_reportf(op->reports, RPT_WARNING, + "Cannot swap '%s' and '%s' as one or both will not be able to fit in their new places", + sa->name, sb->name); + } + } + + /* add strips back to track now */ + BKE_nlatrack_add_strip(nlt, sa); + BKE_nlatrack_add_strip(nlt, sb); + } + + /* clear (temp) metastrips */ + BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); + } + + /* free temp data */ + BLI_freelistN(&anim_data); + + /* refresh auto strip properties */ + ED_nla_postop_refresh(&ac); + + /* set notifier that things have changed */ + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + + /* done */ + return OPERATOR_FINISHED; +} + +void NLA_OT_swap (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Swap Strips"; + ot->idname= "NLA_OT_swap"; + ot->description= "Swap order of selected strips within tracks"; + + /* api callbacks */ + ot->exec= nlaedit_swap_exec; + ot->poll= nlaop_poll_tweakmode_off; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /* ******************** Move Strips Up Operator ************************** */ /* Tries to move the selected strips into the track above if possible. */ diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index 5bf81658fdf..b2ff0e107b3 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -100,6 +100,7 @@ void NLA_OT_split(wmOperatorType *ot); void NLA_OT_mute_toggle(wmOperatorType *ot); +void NLA_OT_swap(wmOperatorType *ot); void NLA_OT_move_up(wmOperatorType *ot); void NLA_OT_move_down(wmOperatorType *ot); diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index c5d6cde62c6..6a32f02c8ad 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -139,6 +139,7 @@ void nla_operatortypes(void) WM_operatortype_append(NLA_OT_mute_toggle); + WM_operatortype_append(NLA_OT_swap); WM_operatortype_append(NLA_OT_move_up); WM_operatortype_append(NLA_OT_move_down); @@ -225,6 +226,9 @@ static void nla_keymap_main (wmKeyConfig *keyconf, wmKeyMap *keymap) /* toggles */ WM_keymap_add_item(keymap, "NLA_OT_mute_toggle", HKEY, KM_PRESS, 0, 0); + /* swap */ + WM_keymap_add_item(keymap, "NLA_OT_swap", FKEY, KM_PRESS, KM_ALT, 0); + /* move up */ WM_keymap_add_item(keymap, "NLA_OT_move_up", PAGEUPKEY, KM_PRESS, 0, 0); /* move down */ diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index bb22b78b2d1..032f4984b83 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -581,6 +581,7 @@ void NLA_OT_click_select (wmOperatorType *ot) /* identifiers */ ot->name= "Mouse Select"; ot->idname= "NLA_OT_click_select"; + ot->description= "Handle clicks to select NLA Strips"; /* api callbacks - absolutely no exec() this yet... */ ot->invoke= nlaedit_clickselect_invoke; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index dc2396f0d15..cf5822d0461 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -194,6 +194,17 @@ void snode_composite_job(const bContext *C, ScrArea *sa) /* ***************************************** */ +/* operator poll callback */ +static int composite_node_active(bContext *C) +{ + if( ED_operator_node_active(C)) { + SpaceNode *snode= CTX_wm_space_node(C); + if(snode->treetype==NTREE_COMPOSIT) + return 1; + } + return 0; +} + /* also checks for edited groups */ bNode *editnode_get_active(bNodeTree *ntree) { @@ -821,7 +832,7 @@ void NODE_OT_backimage_move(wmOperatorType *ot) /* api callbacks */ ot->invoke= snode_bg_viewmove_invoke; ot->modal= snode_bg_viewmove_modal; - ot->poll= ED_operator_node_active; + ot->poll= composite_node_active; /* flags */ ot->flag= OPTYPE_BLOCKING; @@ -849,7 +860,7 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot) /* api callbacks */ ot->exec= backimage_zoom; - ot->poll= ED_operator_node_active; + ot->poll= composite_node_active; /* flags */ ot->flag= OPTYPE_BLOCKING; @@ -1396,7 +1407,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) ListBase *nodelist = MEM_callocN(sizeof(ListBase), "items_list"); bNodeListItem *nli; bNode *node; - int i; + int i, numlinks=0; for(node= snode->edittree->nodes.first; node; node= node->next) { if(node->flag & NODE_SELECT) { @@ -1434,11 +1445,15 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) nodeRemSocketLinks(snode->edittree, sock_to); nodeAddLink(snode->edittree, node_fr, sock_fr, node_to, sock_to); NodeTagChanged(snode->edittree, node_to); + ++numlinks; break; } } - ntreeSolveOrder(snode->edittree); + if (numlinks > 0) { + node_tree_verify_groups(snode->nodetree); + ntreeSolveOrder(snode->edittree); + } BLI_freelistN(nodelist); MEM_freeN(nodelist); @@ -1898,6 +1913,7 @@ void NODE_OT_links_cut(wmOperatorType *ot) /* ******************************** */ // XXX some code needing updating to operators... + /* goes over all scenes, reads render layers */ static int node_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -1935,7 +1951,7 @@ void NODE_OT_read_renderlayers(wmOperatorType *ot) ot->exec= node_read_renderlayers_exec; - ot->poll= ED_operator_node_active; + ot->poll= composite_node_active; /* flags */ ot->flag= 0; @@ -1966,7 +1982,7 @@ void NODE_OT_read_fullsamplelayers(wmOperatorType *ot) ot->exec= node_read_fullsamplelayers_exec; - ot->poll= ED_operator_node_active; + ot->poll= composite_node_active; /* flags */ ot->flag= 0; @@ -2369,7 +2385,7 @@ void NODE_OT_add_file(wmOperatorType *ot) /* callbacks */ ot->exec= node_add_file_exec; ot->invoke= node_add_file_invoke; - ot->poll= ED_operator_node_active; + ot->poll= composite_node_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 748ba847f22..b53ac07aab3 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -137,6 +137,7 @@ void NODE_OT_select(wmOperatorType *ot) /* identifiers */ ot->name= "Select"; ot->idname= "NODE_OT_select"; + ot->description= "Select node under cursor"; /* api callbacks */ ot->invoke= node_select_invoke; diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index fe587bd98d6..dad85626886 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -1409,7 +1409,6 @@ static void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) for(group= mainvar->group.first; group; group= group->id.next) { if(group->gobject.first) { te= outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); - tselem= TREESTORE(te); for(go= group->gobject.first; go; go= go->next) { ten= outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); @@ -1846,6 +1845,7 @@ void OUTLINER_OT_show_one_level(wmOperatorType *ot) /* identifiers */ ot->name= "Show/Hide One Level"; ot->idname= "OUTLINER_OT_show_one_level"; + ot->description= "Expand/collapse all entries by one level"; /* callbacks */ ot->exec= outliner_one_level_exec; @@ -2022,13 +2022,13 @@ static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *so static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) { TreeElement *tep; - TreeStoreElem *tselem, *tselemp; + TreeStoreElem /* *tselem,*/ *tselemp; Object *ob=OBACT; SpaceButs *sbuts=NULL; if(ob==NULL) return 0; // no active object - tselem= TREESTORE(te); + /*tselem= TREESTORE(te);*/ /*UNUSED*/ /* find buttons area (note, this is undefined really still, needs recode in blender) */ /* XXX removed finding sbuts */ @@ -2595,6 +2595,7 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) { ot->name= "Activate Item"; ot->idname= "OUTLINER_OT_item_activate"; + ot->description= "Handle mouse clicks to activate/select items"; ot->invoke= outliner_item_activate; @@ -2657,6 +2658,7 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) { ot->name= "Open/Close Item"; ot->idname= "OUTLINER_OT_item_openclose"; + ot->description= "Toggle whether item under cursor is enabled or closed"; ot->invoke= outliner_item_openclose; @@ -2687,9 +2689,11 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T error("Cannot edit sequence name"); else if(tselem->id->lib) { // XXX error_libdata(); - } else if(te->idcode == ID_LI && te->parent) { + } + else if(te->idcode == ID_LI && te->parent) { error("Cannot edit the path of an indirectly linked library"); - } else { + } + else { tselem->flag |= TSE_TEXTBUT; ED_region_tag_redraw(ar); } @@ -2724,6 +2728,7 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot) { ot->name= "Rename Item"; ot->idname= "OUTLINER_OT_item_rename"; + ot->description= "Rename item under cursor"; ot->invoke= outliner_item_rename; @@ -3778,6 +3783,7 @@ void OUTLINER_OT_operation(wmOperatorType *ot) { ot->name= "Execute Operation"; ot->idname= "OUTLINER_OT_operation"; + ot->description= "Context menu for item operations"; ot->invoke= outliner_operation; @@ -4052,7 +4058,7 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) ot->poll= ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -4087,7 +4093,7 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot) ot->poll= ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } /* ***************** KEYINGSET OPERATIONS *************** */ @@ -4217,14 +4223,15 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) { /* identifiers */ ot->idname= "OUTLINER_OT_keyingset_add_selected"; - ot->name= "Keyingset Add Selected"; + ot->name= "Keying Set Add Selected"; + ot->description= "Add selected items (blue-grey rows) to active Keying Set"; /* api callbacks */ ot->exec= outliner_keyingset_additems_exec; ot->poll= ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -4253,14 +4260,15 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) { /* identifiers */ ot->idname= "OUTLINER_OT_keyingset_remove_selected"; - ot->name= "Keyingset Remove Selected"; + ot->name= "Keying Set Remove Selected"; + ot->description = "Remove selected items (blue-grey rows) from active Keying Set"; /* api callbacks */ ot->exec= outliner_keyingset_removeitems_exec; ot->poll= ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } /* ***************** DRAW *************** */ @@ -4546,7 +4554,6 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa if(level<1 || (tselem->type==0 && te->idcode==ID_OB)) { /* active blocks get white circle */ - active= 0; if(tselem->type==0) { if(te->idcode==ID_OB) active= (OBACT==(Object *)tselem->id); else if(scene->obedit && scene->obedit->data==tselem->id) active= 1; // XXX use context? diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 74c2dd5db1c..0b941e910f8 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -117,6 +117,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) break; case ND_BONE_ACTIVE: case ND_BONE_SELECT: + case ND_DRAW: case ND_PARENT: case ND_OB_SHADING: ED_region_tag_redraw(ar); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 6afe2791ff9..52f4697bad1 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2014,7 +2014,7 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar, /* calculate pixelsize factor once, is used for lamps and obcenters */ { /* note: '1.0f / len_v3(v1)' replaced 'len_v3(rv3d->viewmat[0])' - * because of float point precission problems at large values [#23908] */ + * because of float point precision problems at large values [#23908] */ float v1[3], v2[3]; float len1, len2; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 4eeacd6f05f..bbb52826de6 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -699,7 +699,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) vod->oldx= x; vod->oldy= y; - /* avoid precission loss over time */ + /* avoid precision loss over time */ normalize_qt(rv3d->viewquat); ED_region_tag_redraw(vod->ar); @@ -1364,7 +1364,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in } for(base= scene->base.first; base; base= base->next) { - if(base->lay & v3d->lay) { + if(BASE_VISIBLE(v3d, base)) { onedone= 1; minmax_object(base->object, min, max); } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 4bb263d3ed9..f85bdc437f3 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -218,16 +218,26 @@ void arrows_move_cursor(unsigned short event) static int view3d_selectable_data(bContext *C) { Object *ob = CTX_data_active_object(C); - + if (!ED_operator_region_view3d_active(C)) return 0; - - if (!CTX_data_edit_object(C)) - if (ob && ob->mode & OB_MODE_SCULPT) - return 0; - if (ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT) && !paint_facesel_test(ob)) - return 0; - + + if(ob) { + if (ob->mode & OB_MODE_EDIT) { + if(ob->type == OB_FONT) { + return 0; + } + } + else { + if (ob->mode & OB_MODE_SCULPT) { + return 0; + } + if (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT) && !paint_facesel_test(ob)) { + return 0; + } + } + } + return 1; } diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 33ba1dbb7f9..3f69ce3e8a8 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -118,7 +118,8 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa) if(ED_undo_valid(C, op->type->name)==0) uiLayoutSetEnabled(pa->layout, 0); - uiBlockSetFunc(block, ED_undo_operator_repeat_cb, op, NULL); + /* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */ + uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, op); view3d_panel_operator_redo_operator(C, pa, op); } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 2f7a24d600f..49071af8bdd 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -69,15 +69,21 @@ opengl drawing context */ void view3d_operator_needs_opengl(const bContext *C) { + wmWindow *win = CTX_wm_window(C); ARegion *ar= CTX_wm_region(C); + + view3d_region_operator_needs_opengl(win, ar); +} +void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar) +{ /* for debugging purpose, context should always be OK */ - if(ar->regiontype!=RGN_TYPE_WINDOW) - printf("view3d_operator_needs_opengl error, wrong region\n"); + if ((ar == NULL) || (ar->regiontype!=RGN_TYPE_WINDOW)) + printf("view3d_region_operator_needs_opengl error, wrong region\n"); else { RegionView3D *rv3d= ar->regiondata; - wmSubWindowSet(CTX_wm_window(C), ar->swinid); + wmSubWindowSet(win, ar->swinid); glMatrixMode(GL_PROJECTION); glLoadMatrixf(rv3d->winmat); glMatrixMode(GL_MODELVIEW); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 196b6af84fe..03b03d211d9 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3821,47 +3821,7 @@ void flushTransGraphData(TransInfo *t) } } -/* *************************** Object Transform data ******************* */ - -/* Little helper function for ObjectToTransData used to give certain - * constraints (ChildOf, FollowPath, and others that may be added) - * inverse corrections for transform, so that they aren't in CrazySpace. - * These particular constraints benefit from this, but others don't, hence - * this semi-hack ;-) - Aligorith - */ -static short constraints_list_needinv(TransInfo *t, ListBase *list) -{ - bConstraint *con; - - /* loop through constraints, checking if there's one of the mentioned - * constraints needing special crazyspace corrections - */ - if (list) { - for (con= list->first; con; con=con->next) { - /* only consider constraint if it is enabled, and has influence on result */ - if ((con->flag & CONSTRAINT_DISABLE)==0 && (con->enforce!=0.0)) { - /* (affirmative) returns for specific constraints here... */ - /* constraints that require this regardless */ - if (con->type == CONSTRAINT_TYPE_CHILDOF) return 1; - if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) return 1; - if (con->type == CONSTRAINT_TYPE_CLAMPTO) return 1; - - /* constraints that require this only under special conditions */ - if (con->type == CONSTRAINT_TYPE_ROTLIKE) { - /* CopyRot constraint only does this when rotating, and offset is on */ - bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data; - - if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION)) - return 1; - } - } - } - } - - /* no appropriate candidates found */ - return 0; -} - +/* ******************* Sequencer Transform data ******************* */ /* This function applies the rules for transforming a strip so duplicate * checks dont need to be added in multiple places. @@ -4267,6 +4227,47 @@ static void createTransSeqData(bContext *C, TransInfo *t) } +/* *********************** Object Transform data ******************* */ + +/* Little helper function for ObjectToTransData used to give certain + * constraints (ChildOf, FollowPath, and others that may be added) + * inverse corrections for transform, so that they aren't in CrazySpace. + * These particular constraints benefit from this, but others don't, hence + * this semi-hack ;-) - Aligorith + */ +static short constraints_list_needinv(TransInfo *t, ListBase *list) +{ + bConstraint *con; + + /* loop through constraints, checking if there's one of the mentioned + * constraints needing special crazyspace corrections + */ + if (list) { + for (con= list->first; con; con=con->next) { + /* only consider constraint if it is enabled, and has influence on result */ + if ((con->flag & CONSTRAINT_DISABLE)==0 && (con->enforce!=0.0)) { + /* (affirmative) returns for specific constraints here... */ + /* constraints that require this regardless */ + if (con->type == CONSTRAINT_TYPE_CHILDOF) return 1; + if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) return 1; + if (con->type == CONSTRAINT_TYPE_CLAMPTO) return 1; + + /* constraints that require this only under special conditions */ + if (con->type == CONSTRAINT_TYPE_ROTLIKE) { + /* CopyRot constraint only does this when rotating, and offset is on */ + bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data; + + if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION)) + return 1; + } + } + } + } + + /* no appropriate candidates found */ + return 0; +} + /* transcribe given object into TransData for Transforming */ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) { diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 8a2a52df2c8..0d3e9b94f98 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -880,7 +880,7 @@ static void select_linked(Scene *scene, Image *ima, EditMesh *em, float limit[2] nverts= efa->v4? 4: 3; for(i=0; i<nverts; i++) { - /* make_uv_vert_map_EM sets verts tmp.l to the indicies */ + /* make_uv_vert_map_EM sets verts tmp.l to the indices */ vlist= EM_get_uv_map_vert(vmap, (*(&efa->v1 + i))->tmp.l); startv= vlist; @@ -2452,7 +2452,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe eve->tmp.l=-1; /* index every vert that has a selected UV using it, but only once so as to - * get unique indicies and to count how much to malloc */ + * get unique indices and to count how much to malloc */ for(efa= em->faces.first; efa; efa= efa->next) { tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 6f123200dd3..09069be6d5f 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -154,7 +154,7 @@ ParamHandle *construct_param_handle(Scene *scene, EditMesh *em, short implicit, } } - /* we need the vert indicies */ + /* we need the vert indices */ for(ev= em->verts.first, a=0; ev; ev= ev->next, a++) ev->tmp.l = a; diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index f60c6d03547..5629ead80db 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -137,12 +137,7 @@ typedef struct ImBuf { #define IB_BITMAPFONT (1 << 0) /* this image is a font */ #define IB_BITMAPDIRTY (1 << 1) /* image needs to be saved is not the same as filename */ #define IB_MIPMAP_INVALID (1 << 2) /* image mipmaps are invalid, need recreate */ - -/* From iff.h. This was once moved away by Frank, now Nzc moves it - * back. Such is the way it is... It is a long list of defines, and - * there are a few external defines in the back. Most of the stuff is - * probably imbuf_intern only. This will need to be merged later - * on. */ +#define IB_RECT_INVALID (1 << 3) /* float buffer changed, needs recreation of byte rect */ /** * \name Imbuf Component flags diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 17387c0a4d3..fa823169966 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -277,7 +277,8 @@ short imb_addrectfloatImBuf(ImBuf *ibuf) if(ibuf==NULL) return FALSE; - imb_freerectfloatImBuf(ibuf); + if(ibuf->rect_float) + imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */ size = ibuf->x *ibuf->y; size = size *4 *sizeof(float); diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index 9e2c32765d2..9605185e897 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -188,6 +188,8 @@ void IMB_rect_from_float(struct ImBuf *ibuf) } } } + /* ensure user flag is reset */ + ibuf->userflags &= ~IB_RECT_INVALID; } static void imb_float_from_rect_nonlinear(struct ImBuf *ibuf, float *fbuf) diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 49920219d8c..c0f54898119 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -95,9 +95,9 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) struct ImBuf *ibuf = 0; int use_float = 0; /* for precision higher then 8 use float */ - long signed_offsets[4] = {0,0,0,0}; - int float_divs[4]; - + long signed_offsets[4]= {0, 0, 0, 0}; + int float_divs[4]= {1, 1, 1, 1}; + int index; int w, h, depth; diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 7b53dd9ef77..d79b63e9c38 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -127,8 +127,9 @@ typedef struct Library { #define PREVIEW_MIPMAP_LARGE 1 typedef struct PreviewImage { + /* All values of 2 are really PREVIEW_MIPMAPS */ unsigned int w[2]; - unsigned int h[2]; + unsigned int h[2]; short changed[2]; short changed_timestamp[2]; unsigned int * rect[2]; diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index b12ffac044b..5261ad65776 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -327,7 +327,9 @@ typedef struct bPose { ListBase chanbase; /* list of pose channels, PoseBones in RNA */ struct GHash *chanhash; /* ghash for quicker string lookups */ - short flag, proxy_layer; /* proxy layer: copy from armature, gets synced */ + short flag, pad; + unsigned int proxy_layer; /* proxy layer: copy from armature, gets synced */ + int pad1; float ctime; /* local action time of this pose */ float stride_offset[3]; /* applied to object */ diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 37c6200b91f..6ddad214af4 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -57,9 +57,6 @@ typedef struct Brush { struct ImBuf *icon_imbuf; PreviewImage *preview; char icon_filepath[240]; - int icon_mode; /* store paint mode for which brush's icon was last generated */ - int pad; - float normal_weight; diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h index b7e15808ff0..d0554a7aaa5 100644 --- a/source/blender/makesdna/DNA_ipo_types.h +++ b/source/blender/makesdna/DNA_ipo_types.h @@ -421,10 +421,10 @@ typedef struct Ipo { #define PART_TOTNAM 25 #define PART_EMIT_FREQ 1 -#define PART_EMIT_LIFE 2 +/* #define PART_EMIT_LIFE 2 */ /*UNUSED*/ #define PART_EMIT_VEL 3 #define PART_EMIT_AVE 4 -#define PART_EMIT_SIZE 5 +/* #define PART_EMIT_SIZE 5 */ /*UNUSED*/ #define PART_AVE 6 #define PART_SIZE 7 diff --git a/source/blender/makesdna/DNA_lamp_types.h b/source/blender/makesdna/DNA_lamp_types.h index 5231108a756..1028d733c65 100644 --- a/source/blender/makesdna/DNA_lamp_types.h +++ b/source/blender/makesdna/DNA_lamp_types.h @@ -140,7 +140,7 @@ typedef struct Lamp { #define LA_SHAD_RAY 8192 /* yafray: lamp shadowbuffer flag, softlight */ /* Since it is used with LOCAL lamp, can't use LA_SHAD */ -#define LA_YF_SOFT 16384 +/* #define LA_YF_SOFT 16384 */ /* no longer used */ #define LA_LAYER_SHADOW 32768 #define LA_SHAD_TEX (1<<16) #define LA_SHOW_CONE (1<<17) diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index 89d31586f6b..7656ae6372b 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -339,7 +339,7 @@ typedef struct SoftBody { /* pd->flag: various settings */ #define PFIELD_USEMAX 1 -#define PDEFLE_DEFORM 2 +/*#define PDEFLE_DEFORM 2*/ /*UNUSED*/ #define PFIELD_GUIDE_PATH_ADD 4 /* TODO: do_versions for below */ #define PFIELD_PLANAR 8 /* used for do_versions */ #define PDEFLE_KILL_PART 16 diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index d1dcd2dd29c..5ccb3e62f7d 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -320,7 +320,7 @@ extern Object workob; #define PARSLOW 16 /* (short) transflag */ -#define OB_OFFS_LOCAL 1 +/*#define OB_OFFS_LOCAL 1*/ /*UNUSED*/ /* #define OB_QUAT 2 */ /* never used, free flag */ #define OB_NEG_SCALE 4 #define OB_DUPLI (8+16+256+512+2048) @@ -328,7 +328,7 @@ extern Object workob; #define OB_DUPLIVERTS 16 #define OB_DUPLIROT 32 #define OB_DUPLINOSPEED 64 -#define OB_POWERTRACK 128 +/*#define OB_POWERTRACK 128*/ /*UNUSED*/ #define OB_DUPLIGROUP 256 #define OB_DUPLIFACES 512 #define OB_DUPLIFACES_SCALE 1024 @@ -341,9 +341,9 @@ extern Object workob; #define OB_DRAWKEY 1 #define OB_DRAWKEYSEL 2 #define OB_OFFS_OB 4 -#define OB_OFFS_MAT 8 -#define OB_OFFS_VKEY 16 -#define OB_OFFS_PATH 32 +/* #define OB_OFFS_MAT 8 */ /*UNUSED*/ +/* #define OB_OFFS_VKEY 16 */ /*UNUSED*/ +/* #define OB_OFFS_PATH 32 */ /*UNUSED*/ #define OB_OFFS_PARENT 64 #define OB_OFFS_PARTICLE 128 /* get ipo from from action or not? */ @@ -415,7 +415,7 @@ extern Object workob; /* NOTE: this was used as a proper setting in past, so nullify before using */ #define BA_TEMP_TAG 32 -#define BA_FROMSET 128 +/* #define BA_FROMSET 128 */ /*UNUSED*/ #define BA_TRANSFORM_CHILD 256 /* child of a transformed object */ #define BA_TRANSFORM_PARENT 8192 /* parent of a transformed object */ diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index f140d60d3e9..f009f3a9eb0 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -321,7 +321,7 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in #define PART_CHILD_EFFECT (1<<27) #define PART_CHILD_LONG_HAIR (1<<28) -#define PART_CHILD_RENDER (1<<29) +/* #define PART_CHILD_RENDER (1<<29) */ /*UNUSED*/ #define PART_CHILD_GUIDE (1<<30) #define PART_SELF_EFFECT (1<<22) diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 85a93a87f74..e7302fff6df 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1176,7 +1176,7 @@ typedef enum SculptFlags { /* toolsettings->uvcalc_flag */ #define UVCALC_FILLHOLES 1 -#define UVCALC_NO_ASPECT_CORRECT 2 /* would call this UVCALC_ASPECT_CORRECT, except it should be default with old file */ +/*#define UVCALC_NO_ASPECT_CORRECT 2*/ /* would call this UVCALC_ASPECT_CORRECT, except it should be default with old file */ #define UVCALC_TRANSFORM_CORRECT 4 /* adjust UV's while transforming to avoid distortion */ /* toolsettings->uv_flag */ @@ -1234,10 +1234,10 @@ typedef enum SculptFlags { #define RETOPO 1 #define RETOPO_PAINT 2 -/* toolsettings->retopo_paint_tool */ -#define RETOPO_PEN 1 -#define RETOPO_LINE 2 -#define RETOPO_ELLIPSE 4 +/* toolsettings->retopo_paint_tool */ /*UNUSED*/ +/* #define RETOPO_PEN 1 */ +/* #define RETOPO_LINE 2 */ +/* #define RETOPO_ELLIPSE 4 */ /* toolsettings->skgen_options */ #define SKGEN_FILTER_INTERNAL (1 << 0) diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 0d388066cf2..8c681dc87b7 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -842,12 +842,6 @@ enum { #define B_IMASELHOME 451 #define B_IMASELREMOVEBIP 452 -#define C_BACK 0xBAAAAA -#define C_DARK 0x665656 -#define C_DERK 0x766666 -#define C_HI 0xCBBBBB -#define C_LO 0x544444 - /* nla->flag */ /* flags (1<<0), (1<<1), and (1<<3) are depreceated flags from old blenders */ /* draw timing in seconds instead of frames */ diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index ab3ca025ed5..d429f55eb6c 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -204,7 +204,7 @@ typedef struct View3D { /* View3D->flag (short) */ -#define V3D_DISPIMAGE 1 +/*#define V3D_DISPIMAGE 1*/ /*UNUSED*/ #define V3D_DISPBGPICS 2 #define V3D_HIDE_HELPLINES 4 #define V3D_INVALID_BACKBUF 8 @@ -285,7 +285,7 @@ typedef struct View3D { /* USE = user setting, DRAW = based on selection */ #define V3D_USE_MANIPULATOR 1 #define V3D_DRAW_MANIPULATOR 2 -#define V3D_CALC_MANIPULATOR 4 +/* #define V3D_CALC_MANIPULATOR 4 */ /*UNUSED*/ /* BGPic->flag */ /* may want to use 1 for select ?*/ diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index a29ea4e9152..f47ea06645b 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -169,9 +169,10 @@ typedef struct wmWindow { short monitor; /* multiscreen... no idea how to store yet */ short active; /* set to 1 if an active window, for quick rejects */ short cursor; /* current mouse cursor type */ - short lastcursor; /* for temp waitcursor */ + short lastcursor; /* previous cursor when setting modal one */ + short modalcursor; /* the current modal cursor */ short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */ - short pad2[2]; + short pad2; struct wmEvent *eventstate; /* storage for event system */ diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 05cb3436ce4..d5d9c4c6cb3 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -948,7 +948,7 @@ static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA * static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, char *manualfunc, char *nextfunc) { - /* note on indicies, this is for external functions and ignores skipped values. + /* note on indices, this is for external functions and ignores skipped values. * so the the index can only be checked against the length when there is no 'skip' funcion. */ char *func; @@ -2296,11 +2296,9 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) prop= srna->cont.properties.last; if(prop) fprintf(f, "(PropertyRNA*)&rna_%s_%s}},\n", srna->identifier, prop->identifier); else fprintf(f, "NULL}},\n"); - - fprintf(f, "\tNULL,NULL,\n"); /* PyType - Cant initialize here */ - fprintf(f, "\t"); rna_print_c_string(f, srna->identifier); + fprintf(f, "\t, NULL,NULL\n"); /* PyType - Cant initialize here */ fprintf(f, ", %d, ", srna->flag); rna_print_c_string(f, srna->name); fprintf(f, ", "); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 742483663a6..cc2e5fc909f 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -4206,7 +4206,7 @@ void RNA_parameter_list_begin(ParameterList *parms, ParameterIterator *iter) if(iter->valid) { iter->size= rna_parameter_size_alloc(iter->parm); - iter->data= (((char*)iter->parms->data)+iter->offset); + iter->data= (((char*)iter->parms->data)); /* +iter->offset, always 0 */ } } @@ -4400,7 +4400,7 @@ static int rna_function_format_array_length(const char *format, int ofs, int fle for (; ofs<flen && format[ofs]!=']' && idx<sizeof(*lenbuf)-1; idx++, ofs++) lenbuf[idx]= format[ofs]; - if (ofs<flen && format[ofs++]==']') { + if (ofs<flen && format[ofs+1]==']') { /* XXX put better error reporting for ofs>=flen or idx over lenbuf capacity */ lenbuf[idx]= '\0'; return atoi(lenbuf); diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 2fa93bcecdd..3c71319a322 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -1591,7 +1591,7 @@ static void rna_def_visibility_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "use_visible", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_VISIBILITY_INVISIBLE); - RNA_def_property_ui_text(prop, "Visible", "Set the objects visible. Initialized from the objects render restriction toggle (access in the outliner)"); + RNA_def_property_ui_text(prop, "Visible", "Set the objects visible. Initialized from the object render restriction toggle in physics button"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "use_occlusion", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index e366b0c61b9..a28017e50f6 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -727,23 +727,27 @@ void rna_def_animdata(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); /* this flag as well as the dynamic test must be defined for this to be editable... */ RNA_def_property_editable_func(prop, "rna_AnimData_action_editable"); RNA_def_property_ui_text(prop, "Action", "Active Action for this datablock"); + RNA_def_property_update(prop, NC_ANIMATION, NULL); /* this will do? */ /* Active Action Settings */ prop= RNA_def_property(srna, "action_extrapolation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "act_extendmode"); RNA_def_property_enum_items(prop, nla_mode_extend_items); RNA_def_property_ui_text(prop, "Action Extrapolation", "Action to take for gaps past the Active Action's range (when evaluating with NLA)"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "action_blend_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "act_blendmode"); RNA_def_property_enum_items(prop, nla_mode_blend_items); RNA_def_property_ui_text(prop, "Action Blending", "Method used for combining Active Action's result with result of NLA stack"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "action_influence", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "act_influence"); RNA_def_property_float_default(prop, 1.0f); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Action Influence", "Amount the Active Action contributes to the result of the NLA stack"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ /* Drivers */ prop= RNA_def_property(srna, "drivers", PROP_COLLECTION, PROP_NONE); @@ -755,6 +759,7 @@ void rna_def_animdata(BlenderRNA *brna) prop= RNA_def_property(srna, "use_nla", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ADT_NLA_EVAL_OFF); RNA_def_property_ui_text(prop, "NLA Evaluation Enabled", "NLA stack is evaluated when evaluating this block"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ } /* --- */ diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 7656e543440..f76994f31ea 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -1118,7 +1118,7 @@ static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "add", "rna_Curve_spline_points_add"); RNA_def_function_ui_description(func, "Add a number of points to this spline."); RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_USE_REPORTS); - RNA_def_int(func, "number", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX); /* func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); @@ -1145,7 +1145,7 @@ static void rna_def_curve_spline_bezpoints(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "add", "rna_Curve_spline_bezpoints_add"); RNA_def_function_ui_description(func, "Add a number of points to this spline."); RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_USE_REPORTS); - RNA_def_int(func, "number", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + RNA_def_int(func, "count", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); /* func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index b6b0bd3ae84..454ed7cee71 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -839,7 +839,7 @@ void RNA_def_struct_ui_icon(StructRNA *srna, int icon) PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype) { - StructRNA *srna= DefRNA.laststruct; + /*StructRNA *srna= DefRNA.laststruct;*/ /* invalid for python defined props */ ContainerRNA *cont= cont_; ContainerDefRNA *dcont; PropertyDefRNA *dprop= NULL; @@ -849,7 +849,7 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier char error[512]; if (rna_validate_identifier(identifier, error, 1) == 0) { - fprintf(stderr, "RNA_def_property: property identifier \"%s.%s\" - %s\n", srna->identifier, identifier, error); + fprintf(stderr, "RNA_def_property: property identifier \"%s.%s\" - %s\n", CONTAINER_RNA_ID(cont), identifier, error); DefRNA.error= 1; } @@ -857,7 +857,7 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier /* XXX - toto, detect supertype collisions */ if(rna_findlink(&dcont->properties, identifier)) { - fprintf(stderr, "RNA_def_property: duplicate identifier \"%s.%s\"\n", srna->identifier, identifier); + fprintf(stderr, "RNA_def_property: duplicate identifier \"%s.%s\"\n", CONTAINER_RNA_ID(cont), identifier); DefRNA.error= 1; } @@ -915,7 +915,7 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier case PROP_COLLECTION: break; default: - fprintf(stderr, "RNA_def_property: \"%s.%s\", invalid property type.\n", srna->identifier, identifier); + fprintf(stderr, "RNA_def_property: \"%s.%s\", invalid property type.\n", CONTAINER_RNA_ID(cont), identifier); DefRNA.error= 1; return NULL; } diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 5aa1e8e836f..606dee0aa8b 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -546,12 +546,29 @@ static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, fl *max= MAXFRAMEF; } -static BezTriple *rna_FKeyframe_points_add(FCurve *fcu, float frame, float value, int flag) +static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int flag) { int index= insert_vert_fcurve(fcu, frame, value, flag); return ((fcu->bezt) && (index >= 0))? (fcu->bezt + index) : NULL; } +static void rna_FKeyframe_points_add(FCurve *fcu, int tot) +{ + if(tot > 0) { + if(fcu->totvert) { + BezTriple *nbezt= MEM_callocN(sizeof(BezTriple) * (fcu->totvert + tot), "rna_FKeyframe_points_add"); + memcpy(nbezt, fcu->bezt, sizeof(BezTriple) * fcu->totvert); + MEM_freeN(fcu->bezt); + fcu->bezt= nbezt; + } + else { + fcu->bezt= MEM_callocN(sizeof(BezTriple) * tot, "rna_FKeyframe_points_add"); + } + + fcu->totvert += tot; + } +} + static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, BezTriple *bezt, int do_fast) { int index= (int)(bezt - fcu->bezt); @@ -1326,7 +1343,7 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_sdna(srna, "FCurve"); RNA_def_struct_ui_text(srna, "Keyframe Points", "Collection of keyframe points"); - func= RNA_def_function(srna, "add", "rna_FKeyframe_points_add"); + func= RNA_def_function(srna, "insert", "rna_FKeyframe_points_insert"); RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve."); parm= RNA_def_float(func, "frame", 0.0f, -FLT_MAX, FLT_MAX, "", "X Value of this keyframe point", -FLT_MAX, FLT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -1338,6 +1355,9 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop) parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe"); RNA_def_function_return(func, parm); + func= RNA_def_function(srna, "add", "rna_FKeyframe_points_add"); + RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve."); + RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX); func= RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove"); RNA_def_function_ui_description(func, "Remove keyframe from an fcurve."); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 8f760466513..71d66dffcbe 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -327,11 +327,11 @@ typedef struct ArrayIterator { void *free_ptr; /* will be free'd if set */ int itemsize; - /* array length with no skip functins applied, take care not to compare against index from animsys or python indicies */ + /* array length with no skip functins applied, take care not to compare against index from animsys or python indices */ int length; /* optional skip function, when set the array as viewed by rna can contain only a subset of the members. - * this changes indicies so quick array index lookups are not possible when skip function is used. */ + * this changes indices so quick array index lookups are not possible when skip function is used. */ IteratorSkipFunc skip; } ArrayIterator; @@ -364,9 +364,9 @@ int rna_parameter_size(struct PropertyRNA *parm); int rna_parameter_size_alloc(struct PropertyRNA *parm); // XXX, these should not need to be defined here~! -struct MTex *rna_mtex_texture_slots_add(struct ID *self, struct ReportList *reports); -struct MTex *rna_mtex_texture_slots_create(struct ID *self, struct ReportList *reports, int index); -void rna_mtex_texture_slots_clear(struct ID *self, struct ReportList *reports, int index); +struct MTex *rna_mtex_texture_slots_add(struct ID *self, struct bContext *C, struct ReportList *reports); +struct MTex *rna_mtex_texture_slots_create(struct ID *self, struct bContext *C, struct ReportList *reports, int index); +void rna_mtex_texture_slots_clear(struct ID *self, struct bContext *C, struct ReportList *reports, int index); #endif /* RNA_INTERNAL_H */ diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 2bb47643e14..c31c473512a 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -108,7 +108,7 @@ struct FunctionRNA { /* structs are containers of properties */ ContainerRNA cont; - /* unique identifier */ + /* unique identifier, keep after 'cont' */ const char *identifier; /* various options */ int flag; @@ -283,13 +283,14 @@ struct StructRNA { /* structs are containers of properties */ ContainerRNA cont; + /* unique identifier, keep after 'cont' */ + const char *identifier; + /* python type, this is a subtype of pyrna_struct_Type but used so each struct can have its own type * which is useful for subclassing RNA */ void *py_type; void *blender_type; - /* unique identifier */ - const char *identifier; /* various options */ int flag; @@ -340,4 +341,6 @@ struct BlenderRNA { ListBase structs; }; +#define CONTAINER_RNA_ID(cont) (const char *)(((ContainerRNA *)(cont))+1) + #endif /* RNA_INTERNAL_TYPES_H */ diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 0fdb42f9146..aecb89a0fee 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -276,7 +276,7 @@ static EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *C, Poi return item; } -MTex *rna_mtex_texture_slots_add(ID *self_id, ReportList *reports) +MTex *rna_mtex_texture_slots_add(ID *self_id, struct bContext *C, ReportList *reports) { MTex *mtex= add_mtex_id(self_id, -1); if (mtex == NULL) { @@ -284,10 +284,13 @@ MTex *rna_mtex_texture_slots_add(ID *self_id, ReportList *reports) return NULL; } + /* for redraw only */ + WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C)); + return mtex; } -MTex *rna_mtex_texture_slots_create(ID *self_id, ReportList *reports, int index) +MTex *rna_mtex_texture_slots_create(ID *self_id, struct bContext *C, ReportList *reports, int index) { MTex *mtex; @@ -298,10 +301,13 @@ MTex *rna_mtex_texture_slots_create(ID *self_id, ReportList *reports, int index) mtex= add_mtex_id(self_id, index); + /* for redraw only */ + WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C)); + return mtex; } -void rna_mtex_texture_slots_clear(ID *self_id, ReportList *reports, int index) +void rna_mtex_texture_slots_clear(ID *self_id, struct bContext *C, ReportList *reports, int index) { MTex **mtex_ar; short act; @@ -323,6 +329,9 @@ void rna_mtex_texture_slots_clear(ID *self_id, ReportList *reports, int index) MEM_freeN(mtex_ar[index]); mtex_ar[index]= NULL; } + + /* for redraw only */ + WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C)); } #else @@ -1841,13 +1850,13 @@ static void rna_def_texture_slots(BlenderRNA *brna, PropertyRNA *cprop, const ch /* functions */ func= RNA_def_function(srna, "add", "rna_mtex_texture_slots_add"); RNA_def_function_ui_description(func, "Add a number of points to this spline."); - RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_NO_SELF|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex."); RNA_def_function_return(func, parm); func= RNA_def_function(srna, "create", "rna_mtex_texture_slots_create"); RNA_def_function_ui_description(func, "Add a number of points to this spline."); - RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_NO_SELF|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Slot index to initialize.", 0, INT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); parm= RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex."); @@ -1855,7 +1864,7 @@ static void rna_def_texture_slots(BlenderRNA *brna, PropertyRNA *cprop, const ch func= RNA_def_function(srna, "clear", "rna_mtex_texture_slots_clear"); RNA_def_function_ui_description(func, "Add a number of points to this spline."); - RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_NO_SELF|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Slot index to clar.", 0, INT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); } diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index d0ddc918c3a..f28fec75fe2 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -34,6 +34,9 @@ #include "MEM_guardedalloc.h" +#include "WM_api.h" +#include "WM_types.h" + #ifdef RNA_RUNTIME #include <stdio.h> @@ -43,9 +46,6 @@ #include "BKE_animsys.h" #include "BKE_nla.h" -#include "WM_api.h" -#include "WM_types.h" - #include "ED_anim_api.h" /* temp constant defined for these funcs only... */ @@ -360,6 +360,7 @@ static void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Name", ""); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_NlaStrip_name_set"); RNA_def_struct_name_property(srna, prop); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ /* Enums */ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); @@ -367,16 +368,19 @@ static void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX for now, not editable, since this is dangerous RNA_def_property_enum_items(prop, prop_type_items); RNA_def_property_ui_text(prop, "Type", "Type of NLA Strip"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "extendmode"); RNA_def_property_enum_items(prop, nla_mode_extend_items); RNA_def_property_ui_text(prop, "Extrapolation", "Action to take for gaps past the strip extents"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "blendmode"); RNA_def_property_enum_items(prop, nla_mode_blend_items); RNA_def_property_ui_text(prop, "Blending", "Method used for combining strip's result with accumulated result"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ /* Strip extents */ prop= RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_TIME); @@ -396,32 +400,38 @@ static void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "blendin"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_blend_in_set", NULL); RNA_def_property_ui_text(prop, "Blend In", "Number of frames at start of strip to fade in influence"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "blend_out", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "blendout"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_blend_out_set", NULL); RNA_def_property_ui_text(prop, "Blend Out", ""); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "use_auto_blend", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_AUTO_BLENDS); RNA_def_property_ui_text(prop, "Auto Blend In/Out", "Number of frames for Blending In/Out is automatically determined from overlapping strips"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ /* Action */ prop= RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Action", "Action referenced by this strip"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ /* Action extents */ prop= RNA_def_property(srna, "action_frame_start", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "actstart"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_action_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Action Start Frame", ""); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "action_frame_end", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "actend"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_action_end_frame_set", NULL); RNA_def_property_ui_text(prop, "Action End Frame", ""); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ /* Action Reuse */ prop= RNA_def_property(srna, "repeat", PROP_FLOAT, PROP_NONE); @@ -429,12 +439,14 @@ static void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_repeat_set", NULL); RNA_def_property_range(prop, 0.1f, 1000.0f); /* these limits have currently be chosen arbitarily, but could be extended (minimum should still be > 0 though) if needed... */ RNA_def_property_ui_text(prop, "Repeat", "Number of times to repeat the action range"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "scale"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_scale_set", NULL); RNA_def_property_range(prop, 0.0001f, 1000.0f); /* these limits can be extended, but beyond this, we can get some crazy+annoying bugs due to numeric errors */ RNA_def_property_ui_text(prop, "Scale", "Scaling factor for action"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ /* Strip's F-Curves */ prop= RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE); @@ -455,21 +467,25 @@ static void rna_def_nlastrip(BlenderRNA *brna) prop= RNA_def_property(srna, "influence", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Influence", "Amount the strip contributes to the current result"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "strip_time", PROP_FLOAT, PROP_TIME); RNA_def_property_ui_text(prop, "Strip Time", "Frame of referenced Action to evaluate"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ // TODO: should the animated_influence/time settings be animatable themselves? prop= RNA_def_property(srna, "use_animated_influence", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_USR_INFLUENCE); RNA_def_property_boolean_funcs(prop, NULL, "rna_NlaStrip_animated_influence_set"); RNA_def_property_ui_text(prop, "Animated Influence", "Influence setting is controlled by an F-Curve rather than automatically determined"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "use_animated_time", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_USR_TIME); RNA_def_property_boolean_funcs(prop, NULL, "rna_NlaStrip_animated_time_set"); RNA_def_property_ui_text(prop, "Animated Strip Time", "Strip time is controlled by an F-Curve rather than automatically determined"); - + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ + prop= RNA_def_property(srna, "use_animated_time_cyclic", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_USR_TIME_CYCLIC); RNA_def_property_ui_text(prop, "Cyclic Strip Time", "Cycle the animated time within the action start & end"); @@ -480,18 +496,22 @@ static void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* can be made editable by hooking it up to the necessary NLA API methods */ RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_ACTIVE); RNA_def_property_ui_text(prop, "Active", "NLA Strip is active"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_SELECT); RNA_def_property_ui_text(prop, "Select", "NLA Strip is selected"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_MUTED); RNA_def_property_ui_text(prop, "Muted", "NLA Strip is not evaluated"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "use_reverse", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_REVERSE); RNA_def_property_ui_text(prop, "Reversed", "NLA Strip is played back in reverse order (only when timing is automatically determined)"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ // TODO: // - sync length @@ -548,29 +568,35 @@ static void rna_def_nlatrack(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", ""); RNA_def_struct_name_property(srna, prop); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ /* settings */ prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* can be made editable by hooking it up to the necessary NLA API methods */ RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_ACTIVE); RNA_def_property_ui_text(prop, "Active", "NLA Track is active"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "is_solo", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* can be made editable by hooking it up to the necessary NLA API methods */ RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_SOLO); RNA_def_property_ui_text(prop, "Solo", "NLA Track is evaluated itself (i.e. active Action and all other NLA Tracks in the same AnimData block are disabled)"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_SELECTED); RNA_def_property_ui_text(prop, "Select", "NLA Track is selected"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_MUTED); RNA_def_property_ui_text(prop, "Muted", "NLA Track is not evaluated"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ prop= RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_PROTECTED); RNA_def_property_ui_text(prop, "Locked", "NLA Track is locked"); + RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ } /* --------- */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 7184fd05dcf..5c962145c55 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -524,13 +524,16 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports, b nodeRemSocketLinks(ntree, out); ret= nodeAddLink(ntree, fromnode, in, tonode, out); + + if(ret) { + NodeTagChanged(ntree, tonode); - NodeTagChanged(ntree, tonode); - - ntreeSolveOrder(ntree); + nodeVerifyGroup(ntree); /* update group node socket links*/ - WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); + ntreeSolveOrder(ntree); + WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); + } return ret; } diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index aa5f69e7164..1fabdb8d21c 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -423,6 +423,14 @@ static float rna_PartSetting_linelenhead_get(struct PointerRNA *ptr) return settings->draw_line[1]; } + +static int rna_PartSettings_is_fluid_get(PointerRNA *ptr) +{ + ParticleSettings *part= (ParticleSettings*)ptr->data; + + return part->type == PART_FLUID; +} + static PointerRNA rna_ParticleSystem_active_particle_target_get(PointerRNA *ptr) { ParticleSystem *psys= (ParticleSystem*)ptr->data; @@ -1199,6 +1207,12 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Particle Settings", "Particle settings, reusable by multiple particle systems"); RNA_def_struct_ui_icon(srna, ICON_PARTICLE_DATA); + /* fluid particle type can't be checked from the type value in rna as it's not shown in the menu */ + prop= RNA_def_property(srna, "is_fluid", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_PartSettings_is_fluid_get", NULL); + RNA_def_property_ui_text(prop, "Fluid", "Particles were created by a fluid simulation"); + /* flag */ prop= RNA_def_property(srna, "use_react_start_end", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_REACT_STA_END); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index ae13e5c68d9..040c2175d07 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -160,19 +160,23 @@ static int rna_ParticleEdit_hair_get(PointerRNA *ptr) static int rna_Brush_mode_poll(PointerRNA *ptr, PointerRNA value) { Scene *scene= (Scene *)ptr->id.data; - Object *ob = OBACT; + ToolSettings *ts = scene->toolsettings; Brush *brush= value.id.data; - - /* weak, for object painting we need to check against the object mode - * but for 2D view image painting we always want texture brushes - * this is not quite correct since you could be in object weightpaint - * mode at the same time as the 2D image view, but for now its *good enough* */ - if(ob && ob->mode & OB_MODE_ALL_PAINT) { - return ob->mode & brush->ob_mode; - } - else { - return OB_MODE_TEXTURE_PAINT & brush->ob_mode; - } + int mode = 0; + + /* check the origin of the Paint struct to see which paint + mode to select from */ + + if(ptr->data == &ts->imapaint) + mode = OB_MODE_TEXTURE_PAINT; + else if(ptr->data == ts->sculpt) + mode = OB_MODE_SCULPT; + else if(ptr->data == ts->vpaint) + mode = OB_MODE_VERTEX_PAINT; + else if(ptr->data == ts->wpaint) + mode = OB_MODE_WEIGHT_PAINT; + + return brush->ob_mode & mode; } #else diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 47a619f661a..7073923b05e 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -332,7 +332,7 @@ static void rna_def_near_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property"); + RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); @@ -343,7 +343,7 @@ static void rna_def_near_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "reset_distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "resetdist"); - RNA_def_property_ui_text(prop, "Reset Distance", ""); + RNA_def_property_ui_text(prop, "Reset Distance", "The distance where the sensor forgets the actor"); RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_update(prop, NC_LOGIC, NULL); } @@ -388,7 +388,7 @@ static void rna_def_touch_sensor(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Material"); RNA_def_property_pointer_sdna(prop, NULL, "ma"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material"); + RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)"); /* note: custom set function is ONLY to avoid rna setting a user for this. */ RNA_def_property_pointer_funcs(prop, NULL, "rna_Sensor_touch_material_set", NULL, NULL); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -502,7 +502,7 @@ static void rna_def_armature_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "test_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Test Type", "Type of value and test"); + RNA_def_property_ui_text(prop, "Test", "Type of value and test"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "bone", PROP_STRING, PROP_NONE); @@ -583,13 +583,13 @@ static void rna_def_collision_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Property", "Only look for Objects with this property"); + RNA_def_property_ui_text(prop, "Property", "Only look for Objects with this property (blank = all objects)"); RNA_def_property_update(prop, NC_LOGIC, NULL); //XXX to make a setFunction to create a lookup with all materials in Blend File (not only this object mat.) prop= RNA_def_property(srna, "material", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "materialName"); - RNA_def_property_ui_text(prop, "Material", "Only look for Objects with this material"); + RNA_def_property_ui_text(prop, "Material", "Only look for Objects with this material (blank = all objects)"); RNA_def_property_update(prop, NC_LOGIC, NULL); /*//XXX either use a datablock look up to store the string name (material) @@ -598,7 +598,7 @@ static void rna_def_collision_sensor(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Material"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_pointer_sdna(prop, NULL, "ma"); - RNA_def_property_ui_text(prop, "Material", "Only look for Objects with this material"); + RNA_def_property_ui_text(prop, "Material", "Only look for Objects with this material (blank = all objects)"); */ } @@ -621,7 +621,7 @@ static void rna_def_radar_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Property", "Only look for Objects with this property"); + RNA_def_property_ui_text(prop, "Property", "Only look for Objects with this property (blank = all objects)"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); @@ -629,7 +629,7 @@ static void rna_def_radar_sensor(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Axis", "Specify along which axis the radar cone is cast"); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); RNA_def_property_range(prop, 0.0, 179.9); RNA_def_property_ui_text(prop, "Angle", "Opening angle of the radar cone"); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -686,12 +686,12 @@ static void rna_def_ray_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "propname"); - RNA_def_property_ui_text(prop, "Property", "Only look for Objects with this property"); + RNA_def_property_ui_text(prop, "Property", "Only look for Objects with this property (blank = all objects)"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "material", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "matname"); - RNA_def_property_ui_text(prop, "Material", "Only look for Objects with this material"); + RNA_def_property_ui_text(prop, "Material", "Only look for Objects with this material (blank = all objects)"); RNA_def_property_update(prop, NC_LOGIC, NULL); /* //XXX either use a datablock look up to store the string name (material) @@ -700,7 +700,7 @@ static void rna_def_ray_sensor(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Material"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_pointer_sdna(prop, NULL, "ma"); - RNA_def_property_ui_text(prop, "Material", "Only look for Objects with this material"); + RNA_def_property_ui_text(prop, "Material", "Only look for Objects with this material (blank = all objects)"); */ prop= RNA_def_property(srna, "use_x_ray", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index e0a46203905..05a7bbecaea 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -134,7 +134,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, return derivedData; /* hashes for finding mapping of: - * - vgroups to indicies -> vgroupHash (string, int) + * - vgroups to indices -> vgroupHash (string, int) * - bones to vgroup indices -> boneHash (index of vgroup, dummy) */ vgroupHash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "mask vgroup gh"); diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index e1c14faa3e1..689a30dd2d2 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -266,7 +266,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, step_tot = ((step_tot + 1) * ltmd->iter) - (ltmd->iter - 1); /* will the screw be closed? - * Note! smaller then FLT_EPSILON*100 gives problems with float precission so its never closed. */ + * Note! smaller then FLT_EPSILON*100 gives problems with float precision so its never closed. */ if (fabs(screw_ofs) <= (FLT_EPSILON*100) && fabs(fabs(angle) - (M_PI * 2)) <= (FLT_EPSILON*100)) { close= 1; step_tot--; diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index 013ca7c231f..6485076bde4 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -127,7 +127,7 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3]) } for(edge_iter = BLI_edgehashIterator_new(edge_hash); !BLI_edgehashIterator_isDone(edge_iter); BLI_edgehashIterator_step(edge_iter)) { - /* Get the edge vert indicies, and edge value (the face indicies that use it)*/ + /* Get the edge vert indices, and edge value (the face indices that use it)*/ BLI_edgehashIterator_getKey(edge_iter, (int*)&ed_v1, (int*)&ed_v2); edge_ref = BLI_edgehashIterator_getValue(edge_iter); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_brightness.c b/source/blender/nodes/intern/CMP_nodes/CMP_brightness.c index 889d61fe4fa..6b0d6ff45a0 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_brightness.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_brightness.c @@ -44,15 +44,14 @@ static bNodeSocketType cmp_node_brightcontrast_out[]= { { -1, 0, "" } }; -static void do_brightnesscontrast(bNode *node, float *out, float *in) +static void do_brightnesscontrast(bNode *UNUSED(node), float *out, float *in, float *in_brightness, float *in_contrast) { float i; int c; - float a, b, contrast, brightness, delta, v; - contrast = node->custom2; - brightness = (float)(node->custom1); - brightness = (brightness) / 100.0f; - delta = contrast / 200.0f; + float a, b, v; + float brightness = (*in_brightness) / 100.0f; + float contrast = *in_contrast; + float delta = contrast / 200.0f; a = 1.0f - delta * 2.0f; /* * The algorithm is by Werner D. Streidt @@ -84,10 +83,8 @@ static void node_composit_exec_brightcontrast(void *UNUSED(data), bNode *node, b if(in[0]->data) { CompBuf *stackbuf, *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); - node->custom1 = in[1]->vec[0]; - node->custom2 = in[2]->vec[0]; stackbuf= dupalloc_compbuf(cbuf); - composit1_pixel_processor(node, stackbuf, cbuf, in[0]->vec, do_brightnesscontrast, CB_RGBA); + composit3_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, do_brightnesscontrast, CB_RGBA, CB_VAL, CB_VAL); out[0]->data = stackbuf; if(cbuf != in[0]->data) free_compbuf(cbuf); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_texture.c b/source/blender/nodes/intern/CMP_nodes/CMP_texture.c index d344e9bf959..b2510917ba1 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_texture.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_texture.c @@ -118,7 +118,7 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in, VECCOPY(stackbuf->procedural_offset, in[0]->vec); VECCOPY(stackbuf->procedural_size, in[1]->vec); stackbuf->procedural_type= CB_VAL; - composit1_pixel_processor(node, prevbuf, prevbuf, out[0]->vec, do_copy_value, CB_VAL); + composit1_pixel_processor(node, stackbuf, stackbuf, out[0]->vec, do_copy_value, CB_VAL); stackbuf->rect_procedural= NULL; out[0]->data= stackbuf; @@ -131,7 +131,7 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in, VECCOPY(stackbuf->procedural_offset, in[0]->vec); VECCOPY(stackbuf->procedural_size, in[1]->vec); stackbuf->procedural_type= CB_RGBA; - composit1_pixel_processor(node, prevbuf, prevbuf, out[0]->vec, do_copy_rgba, CB_RGBA); + composit1_pixel_processor(node, stackbuf, stackbuf, out[0]->vec, do_copy_rgba, CB_RGBA); stackbuf->rect_procedural= NULL; out[1]->data= stackbuf; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_image.c b/source/blender/nodes/intern/TEX_nodes/TEX_image.c index c764c7a22d2..7c680b4c25a 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_image.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_image.c @@ -58,7 +58,13 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(i py = (int)( (y-yoff) * ysize ); if( (!xsize) || (!ysize) ) return; - if( !ibuf->rect_float ) IMB_float_from_rect(ibuf); + + if( !ibuf->rect_float ) { + BLI_lock_thread(LOCK_IMAGE); + if( !ibuf->rect_float ) + IMB_float_from_rect(ibuf); + BLI_unlock_thread(LOCK_IMAGE); + } while( px < 0 ) px += ibuf->x; while( py < 0 ) py += ibuf->y; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_output.c b/source/blender/nodes/intern/TEX_nodes/TEX_output.c index 26733a94180..1be2e8f1c56 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_output.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_output.c @@ -45,7 +45,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(o TexParams params; params_from_cdata(¶ms, cdata); - if(in[1]->hasinput && !in[0]->hasinput) + if(in[1] && in[1]->hasinput && !in[0]->hasinput) tex_input_rgba(&target->tr, in[1], ¶ms, cdata->thread); else tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread); @@ -63,7 +63,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(o target->talpha = 1.0f; if(target->nor) { - if(in[1]->hasinput) + if(in[1] && in[1]->hasinput) tex_input_vec(target->nor, in[1], ¶ms, cdata->thread); else target->nor = 0; diff --git a/source/blender/nodes/intern/TEX_util.c b/source/blender/nodes/intern/TEX_util.c index 38f2cd1a306..d288b13a66c 100644 --- a/source/blender/nodes/intern/TEX_util.c +++ b/source/blender/nodes/intern/TEX_util.c @@ -181,6 +181,7 @@ int ntreeTexExecTree( MTex *mtex ){ TexCallData data; + float *nor= texres->nor; int retval = TEX_INT; data.co = co; @@ -199,6 +200,9 @@ int ntreeTexExecTree( if(texres->nor) retval |= TEX_NOR; retval |= TEX_RGB; + /* confusing stuff; the texture output node sets this to NULL to indicate no normal socket was set + however, the texture code checks this for other reasons (namely, a normal is required for material) */ + texres->nor= nor; return retval; } diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 3d525b08ecc..474259fe0e3 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -187,43 +187,60 @@ Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuf #define MAX_DIMENSIONS 256 static PyObject *Method_Buffer (PyObject *UNUSED(self), PyObject *args) { - PyObject *length_ob= NULL, *template= NULL; + PyObject *length_ob= NULL, *init= NULL; Buffer *buffer; int dimensions[MAX_DIMENSIONS]; int i, type; int ndimensions = 0; - if (!PyArg_ParseTuple(args, "iO|O", &type, &length_ob, &template)) { + if (!PyArg_ParseTuple(args, "iO|O", &type, &length_ob, &init)) { PyErr_SetString(PyExc_AttributeError, "expected an int and one or two PyObjects"); return NULL; } - if (type!=GL_BYTE && type!=GL_SHORT && type!=GL_INT && type!=GL_FLOAT && type!=GL_DOUBLE) { + if (!ELEM5(type, GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT, GL_DOUBLE)) { PyErr_SetString(PyExc_AttributeError, "invalid first argument type, should be one of GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT or GL_DOUBLE"); return NULL; } - if (PyNumber_Check(length_ob)) { + if (PyLong_Check(length_ob)) { ndimensions= 1; - dimensions[0]= PyLong_AsLong(length_ob); - } else if (PySequence_Check(length_ob)) { + if(((dimensions[0]= PyLong_AsLong(length_ob)) < 1)) { + PyErr_SetString(PyExc_AttributeError, "dimensions must be between 1 and "STRINGIFY(MAX_DIMENSIONS)); + return NULL; + } + } + else if (PySequence_Check(length_ob)) { ndimensions= PySequence_Size(length_ob); if (ndimensions > MAX_DIMENSIONS) { - PyErr_SetString(PyExc_AttributeError, "too many dimensions, max is 256"); + PyErr_SetString(PyExc_AttributeError, "too many dimensions, max is "STRINGIFY(MAX_DIMENSIONS)); + return NULL; + } + else if (ndimensions < 1) { + PyErr_SetString(PyExc_AttributeError, "sequence must have at least one dimension"); return NULL; } for (i=0; i<ndimensions; i++) { PyObject *ob= PySequence_GetItem(length_ob, i); - if (!PyNumber_Check(ob)) dimensions[i]= 1; + if (!PyLong_Check(ob)) dimensions[i]= 1; else dimensions[i]= PyLong_AsLong(ob); Py_DECREF(ob); + + if(dimensions[i] < 1) { + PyErr_SetString(PyExc_AttributeError, "dimensions must be between 1 and "STRINGIFY(MAX_DIMENSIONS)); + return NULL; + } } } + else { + PyErr_Format(PyExc_TypeError, "invalid second argument argument expected a sequence or an int, not a %.200s", Py_TYPE(length_ob)->tp_name); + return NULL; + } buffer= BGL_MakeBuffer(type, ndimensions, dimensions, NULL); - if (template && ndimensions) { - if (Buffer_ass_slice((PyObject *) buffer, 0, dimensions[0], template)) { + if (init && ndimensions) { + if (Buffer_ass_slice((PyObject *) buffer, 0, dimensions[0], init)) { Py_DECREF(buffer); return NULL; } diff --git a/source/blender/python/generic/mathutils.c b/source/blender/python/generic/mathutils.c index f0eca793028..5b75552ca8d 100644 --- a/source/blender/python/generic/mathutils.c +++ b/source/blender/python/generic/mathutils.c @@ -40,6 +40,7 @@ * - Matrix.scalePart --> Matrix.scale_part * - Matrix.translationPart --> Matrix.translation_part * - Matrix.rotationPart --> Matrix.rotation_part + * - mathutils.Matrix.Shear(plane, fac, size), now takes a pair of floats for 3x3 or 4x4 shear factor. * - toMatrix --> to_matrix * - toEuler --> to_euler * - toQuat --> to_quat @@ -81,8 +82,7 @@ static char M_Mathutils_doc[] = "This module provides access to matrices, eulers, quaternions and vectors."; -/* helper functionm returns length of the 'value', -1 on error */ -int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix) +static int mathutils_array_parse_fast(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix) { PyObject *value_fast= NULL; @@ -117,6 +117,37 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject * return size; } +/* helper functionm returns length of the 'value', -1 on error */ +int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix) +{ +#if 1 /* approx 6x speedup for mathutils types */ + int size; + + if( (VectorObject_Check(value) && (size= ((VectorObject *)value)->size)) || + (EulerObject_Check(value) && (size= 3)) || + (QuaternionObject_Check(value) && (size= 4)) || + (ColorObject_Check(value) && (size= 3)) + ) { + if(!BaseMath_ReadCallback((BaseMathObject *)value)) { + return -1; + } + + if(size > array_max || size < array_min) { + if (array_max == array_min) PyErr_Format(PyExc_ValueError, "%.200s: sequence size is %d, expected %d", error_prefix, size, array_max); + else PyErr_Format(PyExc_ValueError, "%.200s: sequence size is %d, expected [%d - %d]", error_prefix, size, array_min, array_max); + return -1; + } + + memcpy(array, ((BaseMathObject *)value)->data, size * sizeof(float)); + return size; + } + else +#endif + { + return mathutils_array_parse_fast(array, array_min, array_max, value, error_prefix); + } +} + //----------------------------------MATRIX FUNCTIONS-------------------- diff --git a/source/blender/python/generic/mathutils_color.c b/source/blender/python/generic/mathutils_color.c index bc82e11915e..b8dd059fe3c 100644 --- a/source/blender/python/generic/mathutils_color.c +++ b/source/blender/python/generic/mathutils_color.c @@ -276,7 +276,7 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item) } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0) return NULL; if (slicelength <= 0) { @@ -309,7 +309,7 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0) return -1; if (step == 1) diff --git a/source/blender/python/generic/mathutils_euler.c b/source/blender/python/generic/mathutils_euler.c index 5f1a6f44d84..034a51fb814 100644 --- a/source/blender/python/generic/mathutils_euler.c +++ b/source/blender/python/generic/mathutils_euler.c @@ -447,7 +447,7 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item) } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) return NULL; if (slicelength <= 0) { @@ -481,7 +481,7 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) return -1; if (step == 1) diff --git a/source/blender/python/generic/mathutils_geometry.c b/source/blender/python/generic/mathutils_geometry.c index 9280dc4093c..4a1993b00ef 100644 --- a/source/blender/python/generic/mathutils_geometry.c +++ b/source/blender/python/generic/mathutils_geometry.c @@ -332,7 +332,7 @@ static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject* args) static char M_Geometry_tesselate_polygon_doc[] = ".. function:: tesselate_polygon(veclist_list)\n" "\n" -" Takes a list of polylines (each point a vector) and returns the point indicies for a polyline filled with triangles.\n" +" Takes a list of polylines (each point a vector) and returns the point indices for a polyline filled with triangles.\n" "\n" " :arg veclist_list: list of polylines\n" " :rtype: list\n" diff --git a/source/blender/python/generic/mathutils_matrix.c b/source/blender/python/generic/mathutils_matrix.c index c36341269db..22ee59f20a0 100644 --- a/source/blender/python/generic/mathutils_matrix.c +++ b/source/blender/python/generic/mathutils_matrix.c @@ -170,7 +170,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) VectorObject *vec= NULL; char *axis= NULL; int matSize; - double angle; /* use double because of precission problems at high values */ + double angle; /* use double because of precision problems at high values */ float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; @@ -330,8 +330,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; - if(!PyArg_ParseTuple(args, "fi|O!", &factor, &matSize, &vector_Type, &vec)) { - PyErr_SetString(PyExc_TypeError, "mathutils.Matrix.Scale(): expected float int and optional vector"); + if(!PyArg_ParseTuple(args, "fi|O!:Matrix.Scale", &factor, &matSize, &vector_Type, &vec)) { return NULL; } if(matSize != 2 && matSize != 3 && matSize != 4) { @@ -421,8 +420,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; - if(!PyArg_ParseTuple(args, "si|O!", &plane, &matSize, &vector_Type, &vec)) { - PyErr_SetString(PyExc_TypeError, "mathutils.Matrix.OrthoProjection(): expected string and int and optional vector"); + if(!PyArg_ParseTuple(args, "si|O!:Matrix.OrthoProjection", &plane, &matSize, &vector_Type, &vec)) { return NULL; } if(matSize != 2 && matSize != 3 && matSize != 4) { @@ -506,25 +504,24 @@ static char C_Matrix_Shear_doc[] = "\n" " Create a matrix to represent an shear transformation.\n" "\n" -" :arg plane: Can be any of the following: ['X', 'Y', 'XY', 'XZ', 'YZ'], where a single axis is for a 2D matrix.\n" +" :arg plane: Can be any of the following: ['X', 'Y', 'XY', 'XZ', 'YZ'], where a single axis is for a 2D matrix only.\n" " :type plane: string\n" -" :arg factor: The factor of shear to apply.\n" -" :type factor: float\n" +" :arg factor: The factor of shear to apply. For a 3 or 4 *size* matrix pass a pair of floats corrasponding with the *plane* axis.\n" +" :type factor: float or float pair\n" " :arg size: The size of the shear matrix to construct [2, 4].\n" " :type size: int\n" " :return: A new shear matrix.\n" -" :rtype: :class:`Matrix`\n"; - +" :rtype: :class:`Matrix`\n" +; static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) { int matSize; char *plane; - float factor; + PyObject *fac; float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; - if(!PyArg_ParseTuple(args, "sfi", &plane, &factor, &matSize)) { - PyErr_SetString(PyExc_TypeError,"mathutils.Matrix.Shear(): expected string float and int"); + if(!PyArg_ParseTuple(args, "sOi:Matrix.Shear", &plane, &fac, &matSize)) { return NULL; } if(matSize != 2 && matSize != 3 && matSize != 4) { @@ -532,36 +529,60 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) return NULL; } - if((strcmp(plane, "X") == 0) - && matSize == 2) { - mat[0] = 1.0f; - mat[2] = factor; - mat[3] = 1.0f; - } else if((strcmp(plane, "Y") == 0) && matSize == 2) { + if(matSize == 2) { + float const factor= PyFloat_AsDouble(fac); + + if(factor==-1.0 && PyErr_Occurred()) { + PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.Shear(): the factor to be a float"); + return NULL; + } + + /* unit */ mat[0] = 1.0f; - mat[1] = factor; mat[3] = 1.0f; - } else if((strcmp(plane, "XY") == 0) && matSize > 2) { - mat[0] = 1.0f; - mat[4] = 1.0f; - mat[6] = factor; - mat[7] = factor; - } else if((strcmp(plane, "XZ") == 0) && matSize > 2) { - mat[0] = 1.0f; - mat[3] = factor; - mat[4] = 1.0f; - mat[5] = factor; - mat[8] = 1.0f; - } else if((strcmp(plane, "YZ") == 0) && matSize > 2) { + + if(strcmp(plane, "X") == 0) { + mat[2] = factor; + } + else if(strcmp(plane, "Y") == 0) { + mat[1] = factor; + } + else { + PyErr_SetString(PyExc_AttributeError, "Matrix.Shear(): expected: X, Y or wrong matrix size for shearing plane"); + return NULL; + } + } + else { + /* 3 or 4, apply as 3x3, resize later if needed */ + float factor[2]; + + if(mathutils_array_parse(factor, 2, 2, fac, "Matrix.Shear()") < 0) { + return NULL; + } + + /* unit */ mat[0] = 1.0f; - mat[1] = factor; - mat[2] = factor; mat[4] = 1.0f; mat[8] = 1.0f; - } else { - PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.Shear(): expected: x, y, xy, xz, yz or wrong matrix size for shearing plane"); - return NULL; + + if(strcmp(plane, "XY") == 0) { + mat[6] = factor[0]; + mat[7] = factor[1]; + } + else if(strcmp(plane, "XZ") == 0) { + mat[3] = factor[0]; + mat[5] = factor[1]; + } + else if(strcmp(plane, "YZ") == 0) { + mat[1] = factor[0]; + mat[2] = factor[1]; + } + else { + PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.Shear(): expected: X, Y, XY, XZ, YZ"); + return NULL; + } } + if(matSize == 4) { //resize matrix mat[10] = mat[8]; @@ -1556,7 +1577,7 @@ static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item) } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)item, self->rowSize, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)item, self->rowSize, &start, &stop, &step, &slicelength) < 0) return NULL; if (slicelength <= 0) { @@ -1589,7 +1610,7 @@ static int Matrix_ass_subscript(MatrixObject* self, PyObject* item, PyObject* va else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)item, self->rowSize, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)item, self->rowSize, &start, &stop, &step, &slicelength) < 0) return -1; if (step == 1) diff --git a/source/blender/python/generic/mathutils_quat.c b/source/blender/python/generic/mathutils_quat.c index 9d79a86dbcc..7507318dfcb 100644 --- a/source/blender/python/generic/mathutils_quat.c +++ b/source/blender/python/generic/mathutils_quat.c @@ -545,7 +545,7 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item) } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) return NULL; if (slicelength <= 0) { @@ -579,7 +579,7 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) return -1; if (step == 1) @@ -901,7 +901,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw case 2: if (mathutils_array_parse(quat, 3, 3, seq, "mathutils.Quaternion()") == -1) return NULL; - angle= fmod(angle + M_PI*2, M_PI*4) - M_PI*2; /* clamp because of precission issues */ + angle= fmod(angle + M_PI*2, M_PI*4) - M_PI*2; /* clamp because of precision issues */ axis_angle_to_quat(quat, quat, angle); break; /* PyArg_ParseTuple assures no more then 2 */ diff --git a/source/blender/python/generic/mathutils_vector.c b/source/blender/python/generic/mathutils_vector.c index b5ac197abee..a3bf1471813 100644 --- a/source/blender/python/generic/mathutils_vector.c +++ b/source/blender/python/generic/mathutils_vector.c @@ -1369,7 +1369,7 @@ static PyObject *Vector_subscript(VectorObject* self, PyObject* item) } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)item, self->size, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)item, self->size, &start, &stop, &step, &slicelength) < 0) return NULL; if (slicelength <= 0) { @@ -1402,7 +1402,7 @@ static int Vector_ass_subscript(VectorObject* self, PyObject* item, PyObject* va else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)item, self->size, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)item, self->size, &start, &stop, &step, &slicelength) < 0) return -1; if (step == 1) diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index c50c37d0261..be5c9a8f1e0 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -98,7 +98,7 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec list= PyList_New(0); - for(BLI_bpathIterator_init(&bpi, G.main, NULL); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) { + for(BLI_bpathIterator_init(&bpi, G.main, NULL, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) { /* build the list */ if (absolute) { BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded); diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 59f762a0658..161b56d39aa 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -225,7 +225,7 @@ float BPY_driver_exec(ChannelDriver *driver) #else /* evaluate the compiled expression */ if (expr_code) - retval= PyEval_EvalCode((PyCodeObject *)expr_code, bpy_pydriver_Dict, driver_vars); + retval= PyEval_EvalCode((void *)expr_code, bpy_pydriver_Dict, driver_vars); #endif /* decref the driver vars first... */ diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index f2ba9f604be..38efb4523c4 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -62,8 +62,7 @@ static int py_call_level= 0; BPy_StructRNA *bpy_context_module= NULL; /* for fast access */ -// only for tests -#define TIME_PY_RUN +// #define TIME_PY_RUN // simple python tests. prints on exit. #ifdef TIME_PY_RUN #include "PIL_time.h" diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index bdd1f0575bd..38d3c9161db 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -539,7 +539,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw Py_RETURN_NONE; } -static EnumPropertyItem *enum_items_from_py(PyObject *value, PyObject *def, int *defvalue, const short is_enum_flag) +static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, int *defvalue, const short is_enum_flag) { EnumPropertyItem *items= NULL; PyObject *item; @@ -547,12 +547,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *value, PyObject *def, int short def_used= 0; const char *def_cmp= NULL; - if(!PySequence_Check(value)) { - PyErr_SetString(PyExc_TypeError, "EnumProperty(...): expected a sequence of tuples for the enum items"); - return NULL; - } - - seq_len= PySequence_Size(value); + seq_len= PySequence_Fast_GET_SIZE(seq_fast); if(is_enum_flag) { if(seq_len > RNA_ENUM_BITFLAG_SIZE) { @@ -580,17 +575,15 @@ static EnumPropertyItem *enum_items_from_py(PyObject *value, PyObject *def, int for(i=0; i<seq_len; i++) { EnumPropertyItem tmp= {0, "", 0, "", ""}; - item= PySequence_GetItem(value, i); - if(item==NULL || PyTuple_Check(item)==0) { + item= PySequence_Fast_GET_ITEM(seq_fast, i); + if(PyTuple_Check(item)==0) { PyErr_SetString(PyExc_TypeError, "EnumProperty(...): expected a sequence of tuples for the enum items"); if(items) MEM_freeN(items); - Py_XDECREF(item); return NULL; } if(!PyArg_ParseTuple(item, "sss", &tmp.identifier, &tmp.name, &tmp.description)) { PyErr_SetString(PyExc_TypeError, "EnumProperty(...): expected an identifier, name and description in the tuple"); - Py_DECREF(item); return NULL; } @@ -612,8 +605,6 @@ static EnumPropertyItem *enum_items_from_py(PyObject *value, PyObject *def, int } RNA_enum_item_add(&items, &totitem, &tmp); - - Py_DECREF(item); } RNA_enum_item_end(&items, &totitem); @@ -635,6 +626,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *value, PyObject *def, int return NULL; } } + return items; } @@ -661,7 +653,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) PyObject *def= NULL; int id_len; int defvalue=0; - PyObject *items= Py_None; + PyObject *items, *items_fast; EnumPropertyItem *eitems; PropertyRNA *prop; PyObject *pyopts= NULL; @@ -672,15 +664,23 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) BPY_PROPDEF_CHECK(EnumProperty, property_flag_enum_items) - eitems= enum_items_from_py(items, def, &defvalue, (opts & PROP_ENUM_FLAG)!=0); + if(!(items_fast= PySequence_Fast(items, "EnumProperty(...): expected a sequence of tuples for the enum items"))) { + return NULL; + } + + eitems= enum_items_from_py(items_fast, def, &defvalue, (opts & PROP_ENUM_FLAG)!=0); + + Py_DECREF(items_fast); + if(!eitems) return NULL; - prop= RNA_def_enum(srna, id, eitems, defvalue, name, description); + if(opts & PROP_ENUM_FLAG) prop= RNA_def_enum_flag(srna, id, eitems, defvalue, name, description); + else prop= RNA_def_enum(srna, id, eitems, defvalue, name, description); + if(pyopts) { if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN); if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - if(opts & PROP_ENUM_FLAG) RNA_def_property_flag(prop, PROP_ENUM_FLAG); } RNA_def_property_duplicate_pointers(srna, prop); MEM_freeN(eitems); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index d248499656a..8f745bc2756 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1665,7 +1665,7 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject int len= pyrna_prop_array_length(self); Py_ssize_t start, stop, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)key, len, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)key, len, &start, &stop, &step, &slicelength) < 0) return NULL; if (slicelength <= 0) { @@ -1821,7 +1821,7 @@ static int pyrna_prop_array_ass_subscript( BPy_PropertyArrayRNA *self, PyObject int len= RNA_property_array_length(&self->ptr, self->prop); Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)key, len, &start, &stop, &step, &slicelength) < 0) { + if (PySlice_GetIndicesEx((void *)key, len, &start, &stop, &step, &slicelength) < 0) { ret= -1; } else if (slicelength <= 0) { @@ -2213,7 +2213,7 @@ static char pyrna_struct_keyframe_insert_doc[] = "\n" " :arg data_path: path to the property to key, analogous to the fcurve's data path.\n" " :type data_path: string\n" -" :arg index: array index of the property to key. Defaults to -1 which will key all indicies or a single channel if the property is not an array.\n" +" :arg index: array index of the property to key. Defaults to -1 which will key all indices or a single channel if the property is not an array.\n" " :type index: int\n" " :arg frame: The frame on which the keyframe is inserted, defaulting to the current frame.\n" " :type frame: float\n" @@ -2256,7 +2256,7 @@ static char pyrna_struct_keyframe_delete_doc[] = "\n" " :arg data_path: path to the property to remove a key, analogous to the fcurve's data path.\n" " :type data_path: string\n" -" :arg index: array index of the property to remove a key. Defaults to -1 removing all indicies or a single channel if the property is not an array.\n" +" :arg index: array index of the property to remove a key. Defaults to -1 removing all indices or a single channel if the property is not an array.\n" " :type index: int\n" " :arg frame: The frame on which the keyframe is deleted, defaulting to the current frame.\n" " :type frame: float\n" @@ -2300,7 +2300,7 @@ static char pyrna_struct_driver_add_doc[] = "\n" " :arg path: path to the property to drive, analogous to the fcurve's data path.\n" " :type path: string\n" -" :arg index: array index of the property drive. Defaults to -1 for all indicies or a single channel if the property is not an array.\n" +" :arg index: array index of the property drive. Defaults to -1 for all indices or a single channel if the property is not an array.\n" " :type index: int\n" " :return: The driver(s) added.\n" " :rtype: :class:`FCurve` or list if index is -1 with an array property."; @@ -2372,7 +2372,7 @@ static char pyrna_struct_driver_remove_doc[] = "\n" " :arg path: path to the property to drive, analogous to the fcurve's data path.\n" " :type path: string\n" -" :arg index: array index of the property drive. Defaults to -1 for all indicies or a single channel if the property is not an array.\n" +" :arg index: array index of the property drive. Defaults to -1 for all indices or a single channel if the property is not an array.\n" " :type index: int\n" " :return: Success of driver removal.\n" " :rtype: boolean"; @@ -3480,11 +3480,37 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) Py_RETURN_NONE; } +static char pyrna_prop_collection_foreach_get_doc[] = +".. method:: foreach_get(attr, seq)\n" +"\n" +" This is a function to give fast access to attribites within a collection.\n" +"\n" +" .. code-block:: python\n" +"\n" +" collection.foreach_get(someseq, attr)\n" +"\n" +" # Python equivelent\n" +" for i in range(len(seq)): someseq[i] = getattr(collection, attr)\n" +"\n" +; static PyObject *pyrna_prop_collection_foreach_get(BPy_PropertyRNA *self, PyObject *args) { return foreach_getset(self, args, 0); } +static char pyrna_prop_collection_foreach_set_doc[] = +".. method:: foreach_set(attr, seq)\n" +"\n" +" This is a function to give fast access to attribites within a collection.\n" +"\n" +" .. code-block:: python\n" +"\n" +" collection.foreach_set(seq, attr)\n" +"\n" +" # Python equivelent\n" +" for i in range(len(seq)): setattr(collection[i], attr, seq[i])\n" +"\n" +; static PyObject *pyrna_prop_collection_foreach_set(BPy_PropertyRNA *self, PyObject *args) { return foreach_getset(self, args, 1); @@ -3566,8 +3592,8 @@ static struct PyMethodDef pyrna_prop_array_methods[] = { }; static struct PyMethodDef pyrna_prop_collection_methods[] = { - {"foreach_get", (PyCFunction)pyrna_prop_collection_foreach_get, METH_VARARGS, NULL}, - {"foreach_set", (PyCFunction)pyrna_prop_collection_foreach_set, METH_VARARGS, NULL}, + {"foreach_get", (PyCFunction)pyrna_prop_collection_foreach_get, METH_VARARGS, pyrna_prop_collection_foreach_get_doc}, + {"foreach_set", (PyCFunction)pyrna_prop_collection_foreach_set, METH_VARARGS, pyrna_prop_collection_foreach_set_doc}, {"keys", (PyCFunction)pyrna_prop_collection_keys, METH_NOARGS, NULL}, {"items", (PyCFunction)pyrna_prop_collection_items, METH_NOARGS,NULL}, diff --git a/source/blender/render/intern/source/rayobject_octree.c b/source/blender/render/intern/source/rayobject_octree.c index 2637643989e..8a8b102c6fa 100644 --- a/source/blender/render/intern/source/rayobject_octree.c +++ b/source/blender/render/intern/source/rayobject_octree.c @@ -974,10 +974,11 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is) ldz=0; dz= 0; } - + xo=ocx1; yo=ocy1; zo=ocz1; - labdao= ddalabda= MIN3(labdax,labday,labdaz); - + ddalabda= MIN3(labdax,labday,labdaz); + /*labdao= ddalabda;*/ /*NEVER READ*/ + vec2[0]= ox1; vec2[1]= oy1; vec2[2]= oz1; diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 1706d63064c..9563e802945 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -2690,7 +2690,7 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f switch(mtex->texco) { case TEXCO_ANGMAP: /* only works with texture being "real" */ - /* use saacos(), fixes bug [#22398], float precission caused lo[2] to be slightly less then -1.0 */ + /* use saacos(), fixes bug [#22398], float precision caused lo[2] to be slightly less then -1.0 */ if(lo[0] || lo[1]) { /* check for zero case [#24807] */ fact= (1.0/M_PI)*saacos(lo[2])/(sqrt(lo[0]*lo[0] + lo[1]*lo[1])); tempvec[0]= lo[0]*fact; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index a7aad83d471..c9d74cbb39d 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -81,7 +81,8 @@ void WM_window_open_temp (struct bContext *C, struct rcti *position, int type); /* files */ -int WM_read_homefile (struct bContext *C, struct wmOperator *op); +int WM_read_homefile_exec(struct bContext *C, struct wmOperator *op); +int WM_read_homefile (struct bContext *C, struct ReportList *reports, short from_memory); int WM_write_homefile (struct bContext *C, struct wmOperator *op); void WM_read_file (struct bContext *C, const char *name, struct ReportList *reports); int WM_write_file (struct bContext *C, const char *target, int fileflags, struct ReportList *reports, int copy); diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 6034ddce1b5..f0a416e1c6e 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -116,6 +116,9 @@ void WM_cursor_set(wmWindow *win, int curs) GHOST_SetCursorVisibility(win->ghostwin, 1); + if(curs == CURSOR_STD && win->modalcursor) + curs= win->modalcursor; + win->cursor= curs; /* detect if we use system cursor or Blender cursor */ @@ -141,11 +144,13 @@ void WM_cursor_modal(wmWindow *win, int val) { if(win->lastcursor == 0) win->lastcursor = win->cursor; + win->modalcursor = val; WM_cursor_set(win, val); } void WM_cursor_restore(wmWindow *win) { + win->modalcursor = 0; if(win->lastcursor) WM_cursor_set(win, win->lastcursor); win->lastcursor = 0; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index be6700f2ea1..3c312a0c2b3 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1470,21 +1470,26 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) if(event->custom==EVT_DATA_LISTBASE) { ListBase *lb= (ListBase *)event->customdata; wmDrag *drag; + for(drag= lb->first; drag; drag= drag->next) { if(drop->poll(C, drag, event)) { + drop->copy(drag, drop); + /* free the drags before calling operator */ + BLI_freelistN(event->customdata); + event->customdata= NULL; + event->custom= 0; + WM_operator_name_call(C, drop->ot->idname, drop->opcontext, drop->ptr); - //wm_operator_invoke(C, drop->ot, event, drop->ptr, NULL, FALSE); action |= WM_HANDLER_BREAK; /* XXX fileread case */ if(CTX_wm_window(C)==NULL) return action; - BLI_freelistN(event->customdata); - event->customdata= NULL; - event->custom= 0; + /* escape from drag loop, got freed */ + break; } } } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 31cb3172013..80b88309883 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -352,11 +352,10 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports) /* called on startup, (context entirely filled with NULLs) */ /* or called for 'New File' */ /* op can be NULL */ -int WM_read_homefile(bContext *C, wmOperator *op) +int WM_read_homefile(bContext *C, ReportList *reports, short from_memory) { ListBase wmbase; char tstr[FILE_MAXDIR+FILE_MAXFILE]; - int from_memory= op && strcmp(op->type->idname, "WM_OT_read_factory_settings")==0; int success= 0; free_ttfont(); /* still weird... what does it here? */ @@ -369,9 +368,7 @@ int WM_read_homefile(bContext *C, wmOperator *op) } else { tstr[0] = '\0'; from_memory = 1; - if (op) { - BKE_report(op->reports, RPT_INFO, "Config directory with startup.blend file not found."); - } + BKE_report(reports, RPT_INFO, "Config directory with "STRINGIFY(BLENDER_STARTUP_FILE)" file not found."); } } @@ -385,7 +382,7 @@ int WM_read_homefile(bContext *C, wmOperator *op) success = (BKE_read_file(C, tstr, NULL) != BKE_READ_FILE_FAIL); if(U.themes.first==NULL) { - printf("\nError: No valid startup.blend, fall back to built-in default.\n\n"); + printf("\nError: No valid "STRINGIFY(BLENDER_STARTUP_FILE)", fall back to built-in default.\n\n"); success = 0; } } @@ -436,9 +433,14 @@ int WM_read_homefile(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL); CTX_wm_window_set(C, NULL); /* exits queues */ - return OPERATOR_FINISHED; + return TRUE; } +int WM_read_homefile_exec(bContext *C, wmOperator *op) +{ + int from_memory= strcmp(op->type->idname, "WM_OT_read_factory_settings") == 0; + return WM_read_homefile(C, op->reports, from_memory) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; +} void read_history(void) { diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 19bb92d72e0..0d1dfd5fbba 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -136,7 +136,7 @@ void WM_init(bContext *C, int argc, char **argv) BLF_lang_init(); /* get the default database, plus a wm */ - WM_read_homefile(C, NULL); + WM_read_homefile(C, NULL, G.factory_startup); /* note: there is a bug where python needs initializing before loading the * startup.blend because it may contain PyDrivers. It also needs to be after @@ -177,8 +177,11 @@ void WM_init(bContext *C, int argc, char **argv) read_history(); + /* allow a path of "", this is what happens when making a new file */ + /* if(G.main->name[0] == 0) BLI_make_file_string("/", G.main->name, BLI_getDefaultDocumentFolder(), "untitled.blend"); + */ BLI_strncpy(G.lib, G.main->name, FILE_MAX); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index f6b3cfed2eb..5aa2f6c1c50 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -981,25 +981,21 @@ static uiBlock *wm_operator_create_ui(bContext *C, ARegion *ar, void *userData) return block; } +/* operator menu needs undo, for redo callback */ int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - int retval= OPERATOR_CANCELLED; if((op->type->flag & OPTYPE_REGISTER)==0) { BKE_reportf(op->reports, RPT_ERROR, "Operator '%s' does not have register enabled, incorrect invoke function.", op->type->idname); return OPERATOR_CANCELLED; } - if(op->type->exec) { - retval= op->type->exec(C, op); + ED_undo_push_op(C, op); + wm_operator_register(C, op); - /* ED_undo_push_op(C, op), called by wm_operator_finished now. */ - } - - if(retval != OPERATOR_CANCELLED) - uiPupBlock(C, wm_block_create_redo, op); + uiPupBlock(C, wm_block_create_redo, op); - return retval; + return OPERATOR_RUNNING_MODAL; } int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, int height) @@ -1353,7 +1349,7 @@ static void WM_OT_read_homefile(wmOperatorType *ot) ot->description="Open the default file (doesn't save the current file)"; ot->invoke= WM_operator_confirm; - ot->exec= WM_read_homefile; + ot->exec= WM_read_homefile_exec; ot->poll= WM_operator_winactive; } @@ -1364,7 +1360,7 @@ static void WM_OT_read_factory_settings(wmOperatorType *ot) ot->description="Load default file and user preferences"; ot->invoke= WM_operator_confirm; - ot->exec= WM_read_homefile; + ot->exec= WM_read_homefile_exec; ot->poll= WM_operator_winactive; } diff --git a/source/creator/creator.c b/source/creator/creator.c index 7d78bb1e439..71173b7b483 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -247,9 +247,15 @@ static int print_help(int UNUSED(argc), char **UNUSED(argv), void *data) printf ("Misc Options:\n"); BLI_argsPrintArgDoc(ba, "--debug"); BLI_argsPrintArgDoc(ba, "--debug-fpe"); - printf("\n"); - + BLI_argsPrintArgDoc(ba, "--factory-startup"); + printf("\n"); + BLI_argsPrintArgDoc(ba, "--env-system-config"); + BLI_argsPrintArgDoc(ba, "--env-system-datafiles"); + BLI_argsPrintArgDoc(ba, "--env-system-scripts"); + BLI_argsPrintArgDoc(ba, "--env-system-plugins"); + BLI_argsPrintArgDoc(ba, "--env-system-python"); + printf("\n"); BLI_argsPrintArgDoc(ba, "-nojoystick"); BLI_argsPrintArgDoc(ba, "-noglsl"); BLI_argsPrintArgDoc(ba, "-noaudio"); @@ -394,6 +400,34 @@ static int set_fpe(int UNUSED(argc), char **UNUSED(argv), void *UNUSED(data)) return 0; } +static int set_factory_startup(int UNUSED(argc), char **UNUSED(argv), void *UNUSED(data)) +{ + G.factory_startup= 1; + return 0; +} + +static int set_env(int argc, char **argv, void *UNUSED(data)) +{ + /* "--env-system-scripts" --> "BLENDER_SYSTEM_SCRIPTS" */ + + char env[64]= "BLENDER"; + char *ch_dst= env + 7; /* skip BLENDER */ + char *ch_src= argv[0] + 5; /* skip --env */ + + if (argc < 2) { + printf("%s requires one argument\n", argv[0]); + exit(1); + } + + for(; *ch_src; ch_src++, ch_dst++) { + *ch_dst= (*ch_src == '-') ? '_' : (*ch_src)-32; /* toupper() */ + } + + *ch_dst= '\0'; + BLI_setenv(env, argv[1]); + return 1; +} + static int playback_mode(int UNUSED(argc), char **UNUSED(argv), void *UNUSED(data)) { /* not if -b was given first */ @@ -1008,7 +1042,16 @@ void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 1, "-a", NULL, playback_doc, playback_mode, NULL); BLI_argsAdd(ba, 1, "-d", "--debug", debug_doc, debug_mode, ba); - BLI_argsAdd(ba, 1, NULL, "--debug-fpe", "\n\tEnable floating point exceptions", set_fpe, NULL); + BLI_argsAdd(ba, 1, NULL, "--debug-fpe", "\n\tEnable floating point exceptions", set_fpe, NULL); + + BLI_argsAdd(ba, 1, NULL, "--factory-startup", "\n\tSkip reading the "STRINGIFY(BLENDER_STARTUP_FILE)" in the users home directory", set_factory_startup, NULL); + + /* TODO, add user env vars? */ + BLI_argsAdd(ba, 1, NULL, "--env-system-config", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_CONFIG)" environment variable", set_env, NULL); + BLI_argsAdd(ba, 1, NULL, "--env-system-datafiles", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_DATAFILES)" environment variable", set_env, NULL); + BLI_argsAdd(ba, 1, NULL, "--env-system-scripts", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_SCRIPTS)" environment variable", set_env, NULL); + BLI_argsAdd(ba, 1, NULL, "--env-system-plugins", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_PLUGINS)" environment variable", set_env, NULL); + BLI_argsAdd(ba, 1, NULL, "--env-system-python", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_PYTHON)" environment variable", set_env, NULL); /* second pass: custom window stuff */ BLI_argsAdd(ba, 2, "-p", "--window-geometry", "<sx> <sy> <w> <h>\n\tOpen with lower left corner at <sx>, <sy> and width and height as <w>, <h>", prefsize, NULL); @@ -1141,7 +1184,7 @@ int main(int argc, char **argv) BLI_argsParse(ba, 3, NULL, NULL); WM_init(C, argc, argv); - + /* this is properly initialized with user defs, but this is default */ BLI_where_is_temp( btempdir, 1 ); /* call after loading the startup.blend so we can read U.tempdir */ diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp index f0d6083a8fa..60cb4a751bb 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.cpp +++ b/source/gameengine/Converter/BlenderWorldInfo.cpp @@ -188,6 +188,12 @@ float BlenderWorldInfo::getMistColorBlue() return m_mistcolor[2]; } +void BlenderWorldInfo::setBackColor(float r, float g, float b) +{ + m_backgroundcolor[0] = r; + m_backgroundcolor[1] = g; + m_backgroundcolor[2] = b; +} void BlenderWorldInfo::setMistStart( diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h index a430e18223e..29145344d18 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.h +++ b/source/gameengine/Converter/BlenderWorldInfo.h @@ -64,6 +64,12 @@ public: float getMistColorGreen(); float getMistColorBlue(); + void + setBackColor( + float r, + float g, + float b + ); void setMistStart( float d diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index e6ea431ec1c..b4bb34b0331 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -75,8 +75,6 @@ #endif //WIN32 #endif -#define EDITOR_LEVEL_VERSION 0x06 - enum VALUE_OPERATOR { VALUE_MOD_OPERATOR, // % diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index a68938ec834..cace4198ed8 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -296,7 +296,7 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = { /* get button active list -------------------------------------------------- */ const char SCA_JoystickSensor::GetButtonActiveList_doc[] = "getButtonActiveList\n" -"\tReturns a list containing the indicies of the button currently pressed.\n"; +"\tReturns a list containing the indices of the button currently pressed.\n"; PyObject* SCA_JoystickSensor::PyGetButtonActiveList( ) { SCA_Joystick *joy = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex); PyObject *ls = PyList_New(0); diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 109b199f230..b6671c45d7d 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -408,7 +408,13 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) */ excdict= PyDict_Copy(m_pythondictionary); - resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode, excdict, excdict); + +#if PY_VERSION_HEX >= 0x03020000 + resultobj = PyEval_EvalCode((PyObject *)m_bytecode, excdict, excdict); +#else + resultobj = PyEval_EvalCode((PyCodeObject *)m_bytecode, excdict, excdict); +#endif + /* PyRun_SimpleString(m_scriptText.Ptr()); */ break; } diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index 3cedda38201..6fa7e023139 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -181,7 +181,7 @@ PyObject* KX_MeshProxy::PyGetVertex(PyObject* args, PyObject* kwds) RAS_TexVert* vertex = m_meshobj->GetVertex(matindex,vertexindex); if(vertex==NULL) { - PyErr_SetString(PyExc_ValueError, "mesh.getVertex(mat_idx, vert_idx): KX_MeshProxy, could not get a vertex at the given indicies"); + PyErr_SetString(PyExc_ValueError, "mesh.getVertex(mat_idx, vert_idx): KX_MeshProxy, could not get a vertex at the given indices"); return NULL; } diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index f5a9e438e1a..8cc62e2c2fb 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -923,6 +923,11 @@ static PyObject* gPySetBackgroundColor(PyObject*, PyObject* value) { gp_Rasterizer->SetBackColor(vec[0], vec[1], vec[2], vec[3]); } + + KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); + if (wi->hasWorld()) + wi->setBackColor(vec[0], vec[1], vec[2]); + Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_WorldInfo.h b/source/gameengine/Ketsji/KX_WorldInfo.h index 3b3d52f91f7..fb730c5502f 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.h +++ b/source/gameengine/Ketsji/KX_WorldInfo.h @@ -58,6 +58,7 @@ public: virtual float getAmbientColorGreen()=0; virtual float getAmbientColorBlue()=0; + virtual void setBackColor(float,float,float)=0; virtual void setMistStart(float)=0; virtual void setMistDistance(float)=0; virtual void setMistColorRed(float)=0; diff --git a/source/test/CMakeLists.txt b/source/test/CMakeLists.txt new file mode 100644 index 00000000000..b9c0d73fa6c --- /dev/null +++ b/source/test/CMakeLists.txt @@ -0,0 +1,253 @@ +# -*- mode: cmake; indent-tabs-mode: t; -*- +# $Id: CMakeLists.txt 34198 2011-01-09 15:12:08Z campbellbarton $ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributor(s): Jacques Beaurain. +# +# ***** END GPL LICENSE BLOCK ***** + +# --env-system-scripts allows to run without WITH_INSTALL + +# Use '--write-blend=/tmp/test.blend' to view output + + +set(TEST_SRC_DIR ${CMAKE_SOURCE_DIR}/../lib/tests) +set(TEST_OUT_DIR ${CMAKE_BINARY_DIR}/tests) + +#~ if(NOT IS_DIRECTORY ${TEST_SRC_DIR}) +#~ message(FATAL_ERROR "CMake test directory not found!") +#~ endif() + +# all calls to blender use this +set(GENERIC_ARGS --background --factory-startup --env-system-scripts ${CMAKE_SOURCE_DIR}/release/scripts) + + +# OBJ Import tests +add_test(import_obj_cube ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_scene.obj\(filepath='${TEST_SRC_DIR}/io_tests/obj/cube.obj'\) + --md5=4d090508b812b5e08168aa2614746bda --md5_method=SCENE +) + +add_test(import_obj_nurbs_cyclic ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_scene.obj\(filepath='${TEST_SRC_DIR}/io_tests/obj/nurbs_cyclic.obj'\) + --md5=9e0da7b65b4c4f818a203d56af2d3a4b --md5_method=SCENE + --write-blend=/root/foo99.blend +) + +add_test(import_obj_makehuman ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_scene.obj\(filepath='${TEST_SRC_DIR}/io_tests/obj/makehuman.obj'\) + --md5=e0829dc078b0789e1d81f1071235bc4f --md5_method=SCENE +) + +# OBJ Export tests +add_test(export_obj_cube ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + ${TEST_SRC_DIR}/io_tests/blend_geometry/all_quads.blend + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.export_scene.obj\(filepath='${TEST_OUT_DIR}/export_obj_cube.obj',use_selection=False\) + --md5_source=${TEST_OUT_DIR}/export_obj_cube.obj + --md5_source=${TEST_OUT_DIR}/export_obj_cube.mtl + --md5=70bdc394c2726203ad26c085176e3484 --md5_method=FILE +) + +add_test(export_obj_nurbs ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + ${TEST_SRC_DIR}/io_tests/blend_geometry/nurbs.blend + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.export_scene.obj\(filepath='${TEST_OUT_DIR}/export_obj_nurbs.obj',use_selection=False,use_nurbs=True\) + --md5_source=${TEST_OUT_DIR}/export_obj_nurbs.obj + --md5_source=${TEST_OUT_DIR}/export_obj_nurbs.mtl + --md5=a733ae4fa4a591ea9b0912da3af042de --md5_method=FILE +) + +add_test(export_obj_all_objects ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + ${TEST_SRC_DIR}/io_tests/blend_scene/all_objects.blend + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.export_scene.obj\(filepath='${TEST_OUT_DIR}/export_obj_all_objects.obj',use_selection=False,use_nurbs=True\) + --md5_source=${TEST_OUT_DIR}/export_obj_all_objects.obj + --md5_source=${TEST_OUT_DIR}/export_obj_all_objects.mtl + --md5=c835899ca8993495af8a13c2f229629b --md5_method=FILE +) + + + +# PLY Import tests +add_test(import_ply_cube ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_mesh.ply\(filepath='${TEST_SRC_DIR}/io_tests/ply/cube_ascii.ply'\) + --md5=527134343c27fc0ea73115b85fbfd3ac --md5_method=SCENE +) + +add_test(import_ply_bunny ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_mesh.ply\(filepath='${TEST_SRC_DIR}/io_tests/ply/bunny2.ply'\) + --md5=6ea5b8533400a17accf928b8fd024eaa --md5_method=SCENE +) + +add_test(import_ply_small_holes ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_mesh.ply\(filepath='${TEST_SRC_DIR}/io_tests/ply/many_small_holes.ply'\) + --md5=c3093e26ecae5b6d59fbbcf2a0d0b39f --md5_method=SCENE +) + +# PLY Export tests (TODO) + + + +# STL Import tests +add_test(import_stl_cube ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_mesh.stl\(filepath='${TEST_SRC_DIR}/io_tests/stl/cube.stl'\) + --md5=8ceb5bb7e1cb5f4342fa1669988c66b4 --md5_method=SCENE +) + +add_test(import_stl_conrod ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_mesh.stl\(filepath='${TEST_SRC_DIR}/io_tests/stl/conrod.stl'\) + --md5=690a4b8eb9002dcd8631c5a575ea7348 --md5_method=SCENE +) + +add_test(import_stl_knot_max_simplified ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_mesh.stl\(filepath='${TEST_SRC_DIR}/io_tests/stl/knot_max_simplified.stl'\) + --md5=baf82803f45a84ec4ddbad9cef57dd3e --md5_method=SCENE +) + +# STL Export tests (TODO) + + + +# X3D Import +add_test(import_x3d_cube ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_scene.x3d\(filepath='${TEST_SRC_DIR}/io_tests/x3d/color_cube.x3d'\) + --md5=c80538e272812c9d765d43df269d8a9b --md5_method=SCENE +) + +add_test(import_x3d_teapot ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_scene.x3d\(filepath='${TEST_SRC_DIR}/io_tests/x3d/teapot.x3d'\) + --md5=fa19713ff71d4b3893dcbe0ab3a73955 --md5_method=SCENE + --write-blend=/root/foo99.blend +) + +add_test(import_x3d_suzanne_material ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_scene.x3d\(filepath='${TEST_SRC_DIR}/io_tests/x3d/suzanne_material.x3d'\) + --md5=52a59dcf731904ac49953dd82c020ae5 --md5_method=SCENE +) + +# X3D Export +add_test(export_x3d_cube ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + ${TEST_SRC_DIR}/io_tests/blend_geometry/all_quads.blend + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.export_scene.x3d\(filepath='${TEST_OUT_DIR}/export_x3d_cube.x3d',use_selection=False\) + --md5_source=${TEST_OUT_DIR}/export_x3d_cube.x3d + --md5=560ba3762a6604669994f661235ef93c --md5_method=FILE +) + +add_test(export_x3d_nurbs ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + ${TEST_SRC_DIR}/io_tests/blend_geometry/nurbs.blend + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.export_scene.x3d\(filepath='${TEST_OUT_DIR}/export_x3d_nurbs.x3d',use_selection=False\) + --md5_source=${TEST_OUT_DIR}/export_x3d_nurbs.x3d + --md5=078c0ca5a08f123cd2cdac48afb54853 --md5_method=FILE +) + +add_test(export_x3d_all_objects ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + ${TEST_SRC_DIR}/io_tests/blend_scene/all_objects.blend + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.export_scene.x3d\(filepath='${TEST_OUT_DIR}/export_x3d_all_objects.x3d',use_selection=False\) + --md5_source=${TEST_OUT_DIR}/export_x3d_all_objects.x3d + --md5=b4bddb55efd8e34af673ffb42bf4c372 --md5_method=FILE +) + + + +# 3DS Import +add_test(import_3ds_cube ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_scene.autodesk_3ds\(filepath='${TEST_SRC_DIR}/io_tests/3ds/cube.3ds'\) + --md5=cb5a45c35a343c3f5beca2a918472951 --md5_method=SCENE +) + +add_test(import_3ds_hierarchy_lara ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_scene.autodesk_3ds\(filepath='${TEST_SRC_DIR}/io_tests/3ds/hierarchy_lara.3ds'\) + --md5=2e9812099b26ad607fdcf4c7be918c71 --md5_method=SCENE + --write-blend=/root/foo99.blend +) + +add_test(import_3ds_hierarchy_greek_trireme ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.import_scene.autodesk_3ds\(filepath='${TEST_SRC_DIR}/io_tests/3ds/hierarchy_greek_trireme.3ds'\) + --md5=d05b922d7be20356d8409d1f768a3a9a --md5_method=SCENE +) + +# 3DS Export +add_test(export_3ds_cube ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + ${TEST_SRC_DIR}/io_tests/blend_geometry/all_quads.blend + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.export_scene.autodesk_3ds\(filepath='${TEST_OUT_DIR}/export_3ds_cube.3ds',use_selection=False\) + --md5_source=${TEST_OUT_DIR}/export_3ds_cube.3ds + --md5=0df6cfb130052d01e31ef77d391d4cc0 --md5_method=FILE +) + +add_test(export_3ds_nurbs ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + ${TEST_SRC_DIR}/io_tests/blend_geometry/nurbs.blend + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.export_scene.autodesk_3ds\(filepath='${TEST_OUT_DIR}/export_3ds_nurbs.3ds',use_selection=False\) + --md5_source=${TEST_OUT_DIR}/export_3ds_nurbs.3ds + --md5=ba1a6d43346fee3bcadc7e30e3c95935 --md5_method=FILE +) + +add_test(export_3ds_all_objects ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + ${TEST_SRC_DIR}/io_tests/blend_scene/all_objects.blend + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.export_scene.autodesk_3ds\(filepath='${TEST_OUT_DIR}/export_3ds_all_objects.3ds',use_selection=False\) + --md5_source=${TEST_OUT_DIR}/export_3ds_all_objects.3ds + --md5=1523ca2e31cf7d781c7de1e17bd14520 --md5_method=FILE +) + + + +# FBX Export +# 'use_metadata=False' for reliable md5's +add_test(export_fbx_cube ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + ${TEST_SRC_DIR}/io_tests/blend_geometry/all_quads.blend + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.export_scene.fbx\(filepath='${TEST_OUT_DIR}/export_fbx_cube.fbx',use_selection=False,use_metadata=False\) + --md5_source=${TEST_OUT_DIR}/export_fbx_cube.fbx + --md5=ce937e605e493958464d62e6de4a2f9f --md5_method=FILE +) + +add_test(export_fbx_nurbs ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + ${TEST_SRC_DIR}/io_tests/blend_geometry/nurbs.blend + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.export_scene.fbx\(filepath='${TEST_OUT_DIR}/export_fbx_nurbs.fbx',use_selection=False,use_metadata=False\) + --md5_source=${TEST_OUT_DIR}/export_fbx_nurbs.fbx + --md5=e02f0147afba2a4ce1ae110567ac3531 --md5_method=FILE +) + +add_test(export_fbx_all_objects ${EXECUTABLE_OUTPUT_PATH}/blender ${GENERIC_ARGS} + ${TEST_SRC_DIR}/io_tests/blend_scene/all_objects.blend + --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- + --run={'FINISHED'}&bpy.ops.export_scene.fbx\(filepath='${TEST_OUT_DIR}/export_fbx_all_objects.fbx',use_selection=False,use_metadata=False\) + --md5_source=${TEST_OUT_DIR}/export_fbx_all_objects.fbx + --md5=c29a3aa600d2e432e4a521cc1e513ba8 --md5_method=FILE +) diff --git a/source/test/bl_test.py b/source/test/bl_test.py new file mode 100644 index 00000000000..86c5cf81e79 --- /dev/null +++ b/source/test/bl_test.py @@ -0,0 +1,195 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# <pep8 compliant> + +import sys +import os + + +# may split this out into a new file +def replace_bpy_app_version(): + """ So MD5's are pradictable from output which uses blenders versions. + """ + + import bpy + + app = bpy.app + app_fake = type(bpy)("bpy.app") + + for attr in dir(app): + if not attr.startswith("_"): + setattr(app_fake, attr, getattr(app, attr)) + + app_fake.version = 0, 0, 0 + app_fake.version_string = "0.00 (sub 0)" + bpy.app = app_fake + + +def clear_startup_blend(): + import bpy + + for scene in bpy.data.scenes: + for obj in scene.objects: + scene.objects.unlink(obj) + + +def blend_to_md5(): + import bpy + scene = bpy.context.scene + ROUND = 4 + + def matrix2str(matrix): + return "".join([str(round(axis, ROUND)) for vector in matrix for axis in vector]).encode('ASCII') + + def coords2str(seq, attr): + return "".join([str(round(axis, ROUND)) for vertex in seq for axis in getattr(vertex, attr)]).encode('ASCII') + + import hashlib + + md5 = hashlib.new("md5") + md5_update = md5.update + + for obj in scene.objects: + md5_update(matrix2str(obj.matrix_world)) + data = obj.data + + if type(data) == bpy.types.Mesh: + md5_update(coords2str(data.vertices, "co")) + elif type(data) == bpy.types.Curve: + for spline in data.splines: + md5_update(coords2str(spline.bezier_points, "co")) + md5_update(coords2str(spline.points, "co")) + + return md5.hexdigest() + + +def main(): + argv = sys.argv + print(" args:", " ".join(argv)) + argv = argv[argv.index("--") + 1:] + + def arg_extract(arg, optional=True, array=False): + arg += "=" + if array: + value = [] + else: + value = None + + i = 0 + while i < len(argv): + if argv[i].startswith(arg): + item = argv[i][len(arg):] + del argv[i] + i -= 1 + + if array: + value.append(item) + else: + value = item + break + + i += 1 + + if (not value) and (not optional): + print(" '%s' not set" % arg) + sys.exit(1) + + return value + + run = arg_extract("--run", optional=False) + md5 = arg_extract("--md5", optional=False) + md5_method = arg_extract("--md5_method", optional=False) # 'SCENE' / 'FILE' + + # only when md5_method is 'FILE' + md5_source = arg_extract("--md5_source", optional=True, array=True) + + # save blend file, for testing + write_blend = arg_extract("--write-blend", optional=True) + + # ensure files are written anew + for f in md5_source: + if os.path.exists(f): + os.remove(f) + + import bpy + + replace_bpy_app_version() + if not bpy.data.filepath: + clear_startup_blend() + + print(" Running: '%s'" % run) + print(" MD5: '%s'!" % md5) + + try: + result = eval(run) + except: + import traceback + traceback.print_exc() + sys.exit(1) + + if write_blend is not None: + print(" Writing Blend: %s" % write_blend) + bpy.ops.wm.save_mainfile(filepath=write_blend, check_existing=False) + + print(" Result: '%s'" % str(result)) + if not result: + print(" Running: %s -> False" % run) + sys.exit(1) + + if md5_method == 'SCENE': + md5_new = blend_to_md5() + elif md5_method == 'FILE': + if not md5_source: + print(" Missing --md5_source argument") + sys.exit(1) + + for f in md5_source: + if not os.path.exists(f): + print(" Missing --md5_source=%r argument does not point to a file") + sys.exit(1) + + import hashlib + + md5_instance = hashlib.new("md5") + md5_update = md5_instance.update + + for f in md5_source: + md5_update(open(f, "rb").read()) + + md5_new = md5_instance.hexdigest() + + else: + print(" Invalid --md5_method=%s argument is not a valid source") + sys.exit(1) + + if md5 != md5_new: + print(" Running: %s\n MD5 Recieved: %s\n MD5 Expected: %s" % (run, md5_new, md5)) + sys.exit(1) + + print(" Success: %s" % run) + + +if __name__ == "__main__": + # So a python error exits(1) + try: + main() + except: + import traceback + traceback.print_exc() + sys.exit(1) diff --git a/release/test/pep8.py b/source/test/pep8.py index 3ccd7dd79b6..3ccd7dd79b6 100644 --- a/release/test/pep8.py +++ b/source/test/pep8.py diff --git a/release/test/rna_array.py b/source/test/rna_array.py index 06b4735cc0d..06b4735cc0d 100644 --- a/release/test/rna_array.py +++ b/source/test/rna_array.py diff --git a/release/test/rna_info_dump.py b/source/test/rna_info_dump.py index 62c1248d733..62c1248d733 100644 --- a/release/test/rna_info_dump.py +++ b/source/test/rna_info_dump.py |