diff --git a/CMakeLists.txt b/CMakeLists.txt index 77f0bed1dce..38ce8689855 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -948,7 +948,7 @@ elseif(APPLE) # we use precompiled libraries for py 3.2 and up by default # normally cached but not since we include them with blender - set(PYTHON_VERSION 3.2) + set(PYTHON_VERSION 3.2) set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}") # set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet set(PYTHON_LIBRARY python${PYTHON_VERSION}) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 06abaf468dd..102ec73a4e3 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -14,7 +14,7 @@ USE_SDK=True ################### Cocoa & architecture settings ################## ############################################################################# WITH_GHOST_COCOA=True -MACOSX_ARCHITECTURE = 'i386' # valid archs: ppc, i386, ppc64, x86_64 +MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64 cmd = 'uname -p' @@ -104,14 +104,26 @@ BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib' BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg bz2' #bz2 is a standard osx dynlib -# python 3.1 uses precompiled libraries in bf svn /lib by default BF_PYTHON_VERSION = '3.2' -BF_PYTHON = LIBDIR + '/python' -BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}' -# BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}' -BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}' -BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}' -# BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System'] +WITH_OSX_STATICPYTHON = True + +if WITH_OSX_STATICPYTHON: + # python 3.2 uses precompiled libraries in bf svn /lib by default + + BF_PYTHON = LIBDIR + '/python' + BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}' + # BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}' + BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}' + BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}' + # BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System'] +else: + # python 3.2 uses Python-framework additionally installed in /Library/Frameworks + + BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/' + BF_PYTHON_INC = '${BF_PYTHON}${BF_PYTHON_VERSION}/include/python${BF_PYTHON_VERSION}m' + BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}' + #BF_PYTHON_LIB = '' + BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config-3.2m' WITH_BF_OPENAL = True #different lib must be used following version of gcc @@ -315,6 +327,10 @@ if WITH_BF_QUICKTIME: else: PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime'] +if not WITH_OSX_STATICPYTHON: + PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python'] + + #note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4 #for 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore) if MACOSX_DEPLOYMENT_TARGET == '10.7': diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index 2f8fa297667..2950ca9380f 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -40,7 +40,7 @@ BF_JACK_INC = '${BF_JACK}/include ${BF_FFMPEG}/include/msvc' BF_JACK_LIB = 'libjack' BF_JACK_LIBPATH = '${BF_JACK}/lib' -WITH_BF_SNDFILE = False +WITH_BF_SNDFILE = True BF_SNDFILE = LIBDIR + '/sndfile' BF_SNDFILE_INC = '${BF_SNDFILE}/include' BF_SNDFILE_LIB = 'libsndfile-1' diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 94d09732be7..c537e435de8 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -536,7 +536,10 @@ def AppIt(target=None, source=None, env=None): print("Installing to %s"%(installdir)) # TODO, use tar. python_zip = 'python_' + osxarch + '.zip' # set specific python_arch.zip - print("unzipping to app-bundle: %s"%(python_zip)) + if env['WITH_OSX_STATICPYTHON']: + print("unzipping to app-bundle: %s"%(python_zip)) + else: + print("dynamic build - make sure to have python3.x-framework installed") bldroot = env.Dir('.').abspath binary = env['BINARYKIND'] @@ -569,10 +572,11 @@ def AppIt(target=None, source=None, env=None): commands.getoutput(cmd) cmd = 'cp %s/release/bin/%s/.Blanguages %s/%s.app/Contents/Resources/'%(bldroot,VERSION,installdir,binary) commands.getoutput(cmd) - cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/python/'%(installdir,binary, VERSION) - commands.getoutput(cmd) - cmd = 'unzip -q %s/release/%s -d %s/%s.app/Contents/MacOS/%s/python/'%(libdir,python_zip,installdir,binary,VERSION) - commands.getoutput(cmd) + if env['WITH_OSX_STATICPYTHON']: + cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/python/'%(installdir,binary, VERSION) + commands.getoutput(cmd) + cmd = 'unzip -q %s/release/%s -d %s/%s.app/Contents/MacOS/%s/python/'%(libdir,python_zip,installdir,binary,VERSION) + commands.getoutput(cmd) if binary == 'blender':#not copy everything for blenderplayer cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/%s/'%(bldroot,installdir,binary,VERSION) diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index d222c0bcc18..be059241727 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -78,7 +78,7 @@ def print_arguments(args, bc): def validate_arguments(args, bc): opts_list = [ - 'WITH_BF_PYTHON', 'WITH_BF_PYTHON_SAFETY', 'BF_PYTHON', 'BF_PYTHON_VERSION', 'BF_PYTHON_INC', 'BF_PYTHON_BINARY', 'BF_PYTHON_LIB', 'BF_PYTHON_LIBPATH', 'WITH_BF_STATICPYTHON', 'BF_PYTHON_LIB_STATIC', 'BF_PYTHON_DLL', 'BF_PYTHON_ABI_FLAGS', + 'WITH_BF_PYTHON', 'WITH_BF_PYTHON_SAFETY', 'BF_PYTHON', 'BF_PYTHON_VERSION', 'BF_PYTHON_INC', 'BF_PYTHON_BINARY', 'BF_PYTHON_LIB', 'BF_PYTHON_LIBPATH', 'WITH_BF_STATICPYTHON', 'WITH_OSX_STATICPYTHON', 'BF_PYTHON_LIB_STATIC', 'BF_PYTHON_DLL', 'BF_PYTHON_ABI_FLAGS', 'WITH_BF_OPENAL', 'BF_OPENAL', 'BF_OPENAL_INC', 'BF_OPENAL_LIB', 'BF_OPENAL_LIBPATH', 'WITH_BF_STATICOPENAL', 'BF_OPENAL_LIB_STATIC', 'WITH_BF_SDL', 'BF_SDL', 'BF_SDL_INC', 'BF_SDL_LIB', 'BF_SDL_LIBPATH', 'BF_LIBSAMPLERATE', 'BF_LIBSAMPLERATE_INC', 'BF_LIBSAMPLERATE_LIB', 'BF_LIBSAMPLERATE_LIBPATH', 'WITH_BF_STATICLIBSAMPLERATE', 'BF_LIBSAMPLERATE_LIB_STATIC', @@ -230,6 +230,7 @@ def read_opts(env, cfg, args): ('BF_PYTHON_LIBPATH', 'Library path', ''), ('BF_PYTHON_LINKFLAGS', 'Python link flags', ''), (BoolVariable('WITH_BF_STATICPYTHON', 'Staticly link to python', False)), + (BoolVariable('WITH_OSX_STATICPYTHON', 'Staticly link to python', True)), ('BF_PYTHON_ABI_FLAGS', 'Python ABI flags (suffix in library version: m, mu, etc)', ''), (BoolVariable('BF_NO_ELBEEM', 'Disable Fluid Sim', False)), diff --git a/doc/python_api/rst/bge.render.rst b/doc/python_api/rst/bge.render.rst index 10514049a8a..eeb50a833ff 100644 --- a/doc/python_api/rst/bge.render.rst +++ b/doc/python_api/rst/bge.render.rst @@ -215,7 +215,19 @@ Functions :type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures) :rtype: boolean +.. function:: setAnisotropicFiltering(level) + Set the anisotropic filtering level for textures. + + :arg level: The new anisotropic filtering level to use + :type level: integer (must be one of 1, 2, 4, 8, 16) + +.. function:: getAnisotropicFiltering() + + Get the anisotropic filtering level used for textures. + + :rtype: integer (one of 1, 2, 4, 8, 16) + .. function:: drawLine(fromVec,toVec,color) Draw a line in the 3D scene. diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index d1fc8593e42..b1277df4c90 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -1539,62 +1539,66 @@ Game Types (bge.types) Return the value matching key, or the default value if its not found. :return: The key value or a default. - .. method:: playAction(name, start_frame, end_frame, layer=0, priority=0 blendin=0, play_mode=ACT_MODE_PLAY, layer_weight=0.0, ipo_flags=0, speed=1.0) + .. method:: playAction(name, start_frame, end_frame, layer=0, priority=0, blendin=0, play_mode=ACT_MODE_PLAY, layer_weight=0.0, ipo_flags=0, speed=1.0) Plays an action. - + :arg name: the name of the action - :type name: string + :type name: string :arg start: the start frame of the action - :type start: float + :type start: float :arg end: the end frame of the action - :type end: float + :type end: float :arg layer: the layer the action will play in (actions in different layers are added/blended together) - :type layer: integer + :type layer: integer :arg priority: only play this action if there isn't an action currently playing in this layer with a higher (lower number) priority - :type priority: integer + :type priority: integer :arg blendin: the amount of blending between this animation and the previous one on this layer - :type blendin: float + :type blendin: float :arg play_mode: the play mode - :type play_mode: KX_ACTION_PLAY, KX_ACTION_LOOP, or KX_ACTION_PING_PONG + :type play_mode: KX_ACTION_MODE_PLAY, KX_ACTION_MODE_LOOP, or KX_ACTION_MODE_PING_PONG :arg layer_weight: how much of the previous layer to use for blending (0 = add) - :type layer_weight: float + :type layer_weight: float :arg ipo_flags: flags for the old IPO behaviors (force, etc) - :type ipo_flags: int bitfield + :type ipo_flags: int bitfield :arg speed: the playback speed of the action as a factor (1.0 = normal speed, 2.0 = 2x speed, etc) - :type speed: float + :type speed: float .. method:: stopAction(layer=0) - Stop playing the action on the given layer. - - :arg layer: The layer to stop playing. - :type layer: integer - + Stop playing the action on the given layer. + + :arg layer: The layer to stop playing. + :type layer: integer + .. method:: getActionFrame(layer=0) Gets the current frame of the action playing in the supplied layer. - - :arg layer: The layer that you want to get the frame from. - :type layer: integer - - :return: The current frame of the action - + + :arg layer: The layer that you want to get the frame from. + :type layer: integer + + :return: The current frame of the action + :rtype: float + .. method:: setActionFrame(frame, layer=0) Set the current frame of the action playing in the supplied layer. - - :arg layer: The layer where you want to set the frame - :type layer: integer - :arg frame: The frame to set the action to - :type frame: float + + :arg layer: The layer where you want to set the frame + :type layer: integer + :arg frame: The frame to set the action to + :type frame: float .. method:: isPlayingAction(layer=0) Checks to see if there is an action playing in the given layer. - - :arg layer: The layer to check for a playing action. - :type layer: integer + + :arg layer: The layer to check for a playing action. + :type layer: integer + + :return: Whether or not the action is playing + :rtype: boolean .. class:: KX_IpoActuator(SCA_IActuator) diff --git a/doc/python_api/rst/info_tips_and_tricks.rst b/doc/python_api/rst/info_tips_and_tricks.rst new file mode 100644 index 00000000000..bd5faf000c8 --- /dev/null +++ b/doc/python_api/rst/info_tips_and_tricks.rst @@ -0,0 +1,57 @@ +############### +Tips and Tricks +############### + +Some of these are just python features that scripters may not have thaught to use with blender. + + +**************** +Use The Terminal +**************** + +For Linux and OSX users this means starting the terminal first, then running blender from within it. on Windows the terminal can be enabled from the help menu. + +******************** +Run External Scripts +******************** + + +****************** +Don't Use Blender! +****************** + + +****************** +Use External Tools +****************** + + +************** +Bundled Python +************** + +Blender from blender.org includes a compleate python installation on all platforms, this has the disadvantage that any extensions you have installed in you're systems python wont be found by blender. + +There are 2 ways around this: + +* remove blender python subdirectory, blender will then look for the systems python and use that instead **python version must match the one that blender comes with**. + +* copy the extensions into blender's python subdirectry so blender can access them, you could also copy the entire python installation into blenders subdirectory, replacing the one blender comes with. This works as long as the python versions match and the paths are created in the same location relative locations. Doing this has the advantage that you can redistribute this bundle to others with blender and/or the game player, including any extensions you rely on. + +******** +Advanced +******** + + +=================== +Blender as a module +=================== + + +============================ +Python Safety (Build Option) +============================ + +================= +CTypes in Blender +================= diff --git a/intern/audaspace/intern/AUD_JOSResampleReaderCoeff.cpp b/intern/audaspace/intern/AUD_JOSResampleReaderCoeff.cpp index 19ebfc00d25..59c69301a02 100644 --- a/intern/audaspace/intern/AUD_JOSResampleReaderCoeff.cpp +++ b/intern/audaspace/intern/AUD_JOSResampleReaderCoeff.cpp @@ -1,3 +1,33 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * Copyright 2009-2011 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * Audaspace 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. + * + * AudaSpace 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 Audaspace; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file audaspace/intern/AUD_JOSResampleReaderCoeff.cpp + * \ingroup audaspaceintern + */ + #include "AUD_JOSResampleReader.h" // sinc filter coefficients, Nz = 136, L = 2304, freq = 0.963904, Kaiser Window B = 16 diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.cpp b/intern/audaspace/intern/AUD_SoftwareDevice.cpp index 496ad6992bc..0413c488b5d 100644 --- a/intern/audaspace/intern/AUD_SoftwareDevice.cpp +++ b/intern/audaspace/intern/AUD_SoftwareDevice.cpp @@ -516,7 +516,7 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::setVolumeMaximum(float volume) float AUD_SoftwareDevice::AUD_SoftwareHandle::getVolumeMinimum() { if(!m_status) - return std::numeric_limits::quiet_NaN();; + return std::numeric_limits::quiet_NaN(); return m_volume_min; } @@ -634,7 +634,7 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::setConeAngleInner(float angle) float AUD_SoftwareDevice::AUD_SoftwareHandle::getConeVolumeOuter() { if(!m_status) - return std::numeric_limits::quiet_NaN();; + return std::numeric_limits::quiet_NaN(); return m_cone_volume_outer; } diff --git a/intern/ghost/intern/GHOST_ISystemPaths.cpp b/intern/ghost/intern/GHOST_ISystemPaths.cpp index 8873398a320..1aa043ebc80 100644 --- a/intern/ghost/intern/GHOST_ISystemPaths.cpp +++ b/intern/ghost/intern/GHOST_ISystemPaths.cpp @@ -70,7 +70,7 @@ GHOST_TSuccess GHOST_ISystemPaths::create() # ifdef GHOST_COCOA m_systemPaths = new GHOST_SystemPathsCocoa (); # else - m_systemPaths = new GHOST_SystemPathsarbon (); + m_systemPaths = new GHOST_SystemPathsCarbon (); # endif # else m_systemPaths = new GHOST_SystemPathsX11 (); diff --git a/intern/ghost/intern/GHOST_Path-api.cpp b/intern/ghost/intern/GHOST_Path-api.cpp index dee66029d19..053eb7d03e8 100644 --- a/intern/ghost/intern/GHOST_Path-api.cpp +++ b/intern/ghost/intern/GHOST_Path-api.cpp @@ -39,7 +39,7 @@ GHOST_TSuccess GHOST_CreateSystemPaths(void) { - return GHOST_ISystemPaths::create();; + return GHOST_ISystemPaths::create(); } GHOST_TSuccess GHOST_DisposeSystemPaths(void) diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp index d5e5fbc7a58..e02e569cc6e 100644 --- a/intern/ghost/intern/GHOST_SystemCarbon.cpp +++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp @@ -48,7 +48,9 @@ #include "GHOST_EventButton.h" #include "GHOST_EventCursor.h" #include "GHOST_EventWheel.h" +#ifdef WITH_INPUT_NDOF #include "GHOST_EventNDOF.h" +#endif #include "GHOST_TimerManager.h" #include "GHOST_TimerTask.h" @@ -1101,7 +1103,9 @@ OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, Even GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) userData; OSStatus err = eventNotHandledErr; GHOST_IWindow* window; +#ifdef WITH_INPUT_NDOF GHOST_TEventNDOFData data; +#endif UInt32 kind; switch (::GetEventClass(event)) @@ -1122,6 +1126,7 @@ OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, Even err = sys->handleKeyEvent(event); break; case kEventClassBlender : +#ifdef WITH_INPUT_NDOF window = sys->m_windowManager->getActiveWindow(); sys->m_ndofManager->GHOST_NDOFGetDatas(data); kind = ::GetEventKind(event); @@ -1137,6 +1142,7 @@ OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, Even // printf("button\n"); break; } +#endif err = noErr; break; default : diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 0c8c0adf041..d9a495ad0f4 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -866,6 +866,8 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp { // Make sure we don't screw up the context + if (m_hGlRc == s_firsthGLRc) + s_firsthGLRc = NULL; m_drawingContextType = GHOST_kDrawingContextTypeOpenGL; removeDrawingContext(); diff --git a/intern/guardedalloc/MEM_sys_types.h b/intern/guardedalloc/MEM_sys_types.h index c5148e84ffe..48230db23a3 100644 --- a/intern/guardedalloc/MEM_sys_types.h +++ b/intern/guardedalloc/MEM_sys_types.h @@ -88,7 +88,7 @@ typedef unsigned long uintptr_t; #define _UINTPTR_T_DEFINED #endif -#elif defined(__linux__) || defined(__NetBSD__) +#elif defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) /* Linux-i386, Linux-Alpha, Linux-ppc */ #include diff --git a/intern/iksolver/intern/IK_QSegment.cpp b/intern/iksolver/intern/IK_QSegment.cpp index df4fbc8fadd..ba4fbb88542 100644 --- a/intern/iksolver/intern/IK_QSegment.cpp +++ b/intern/iksolver/intern/IK_QSegment.cpp @@ -319,7 +319,7 @@ void IK_QSegment::RemoveChild(IK_QSegment *child) else { IK_QSegment *seg = m_child; - while (seg->m_sibling != child); + while (seg->m_sibling != child) seg = seg->m_sibling; if (child == seg->m_sibling) diff --git a/intern/opennl/superlu/superlu_sys_types.h b/intern/opennl/superlu/superlu_sys_types.h index 2cd9cab453d..c154b4c50ac 100644 --- a/intern/opennl/superlu/superlu_sys_types.h +++ b/intern/opennl/superlu/superlu_sys_types.h @@ -89,7 +89,7 @@ typedef unsigned long uintptr_t; #define _UINTPTR_T_DEFINED #endif -#elif defined(__linux__) || defined(__NetBSD__) +#elif defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) /* Linux-i386, Linux-Alpha, Linux-ppc */ #include diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index e17064178b8..463ba84470f 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -185,9 +185,13 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel): layout.template_ID(ob, "pose_library", new="poselib.new", unlink="poselib.unlink") if poselib: + + # list of poses in pose library row = layout.row() row.template_list(poselib, "pose_markers", poselib.pose_markers, "active_index", rows=5) - + + # column of operators for active pose + # - goes beside list col = row.column(align=True) col.active = (poselib.library is None) @@ -202,8 +206,12 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel): if pose_marker_active is not None: col.operator("poselib.pose_remove", icon='ZOOMOUT', text="").pose = pose_marker_active.name col.operator("poselib.apply_pose", icon='ZOOM_SELECTED', text="").pose_index = poselib.pose_markers.active_index - - layout.operator("poselib.action_sanitise") + + col.operator("poselib.action_sanitise", icon='HELP', text="") # XXX: put in menu? + + # properties for active marker + if pose_marker_active is not None: + layout.prop(pose_marker_active, "name") # TODO: this panel will soon be depreceated too diff --git a/release/scripts/startup/bl_ui/properties_game.py b/release/scripts/startup/bl_ui/properties_game.py index e3c576e7093..161e4b10cff 100644 --- a/release/scripts/startup/bl_ui/properties_game.py +++ b/release/scripts/startup/bl_ui/properties_game.py @@ -340,10 +340,12 @@ class RENDER_PT_game_performance(RenderButtonsPanel, Panel): layout = self.layout gs = context.scene.game_settings - row = layout.row() + col = layout.column() + row = col.row() row.prop(gs, "use_frame_rate") row.prop(gs, "use_display_lists") - row.prop(gs, "restrict_animation_updates") + + col.prop(gs, "restrict_animation_updates") class RENDER_PT_game_display(RenderButtonsPanel, Panel): diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 708b3708ab7..fb6505fe935 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -213,7 +213,7 @@ void blf_font_buffer(FontBLF *font, const char *str) { unsigned char *cbuf; unsigned int c; - unsigned char b_col_char[3]; + unsigned char b_col_char[4]; GlyphBLF *g, *g_prev; FT_Vector delta; FT_UInt glyph_index; @@ -232,6 +232,7 @@ void blf_font_buffer(FontBLF *font, const char *str) b_col_char[0]= font->b_col[0] * 255; b_col_char[1]= font->b_col[1] * 255; b_col_char[2]= font->b_col[2] * 255; + b_col_char[3]= font->b_col[3] * 255; while (str[i]) { int pen_y; @@ -296,16 +297,19 @@ void blf_font_buffer(FontBLF *font, const char *str) a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f; if(a > 0.0f) { + float alphatest; fbuf= font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); if (a >= 1.0f) { fbuf[0]= font->b_col[0]; fbuf[1]= font->b_col[1]; fbuf[2]= font->b_col[2]; + fbuf[3]= (alphatest= (fbuf[3] + (font->b_col[3]))) < 1.0f ? alphatest : 1.0f; } else { fbuf[0]= (font->b_col[0]*a) + (fbuf[0] * (1-a)); fbuf[1]= (font->b_col[1]*a) + (fbuf[1] * (1-a)); fbuf[2]= (font->b_col[2]*a) + (fbuf[2] * (1-a)); + fbuf[3]= (alphatest= (fbuf[3] + (font->b_col[3]*a))) < 1.0f ? alphatest : 1.0f; } } } @@ -324,16 +328,19 @@ void blf_font_buffer(FontBLF *font, const char *str) a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f; if(a > 0.0f) { + int alphatest; cbuf= font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); if (a >= 1.0f) { cbuf[0]= b_col_char[0]; cbuf[1]= b_col_char[1]; cbuf[2]= b_col_char[2]; + cbuf[3]= (alphatest= ((int)cbuf[3] + (int)b_col_char[3])) < 255 ? alphatest : 255; } else { cbuf[0]= (b_col_char[0]*a) + (cbuf[0] * (1-a)); cbuf[1]= (b_col_char[1]*a) + (cbuf[1] * (1-a)); cbuf[2]= (b_col_char[2]*a) + (cbuf[2] * (1-a)); + cbuf[3]= (alphatest= ((int)cbuf[3] + (int)((font->b_col[3]*a)*255.0f))) < 255 ? alphatest : 255; } } } diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index e2a1b0dfb33..ed073f03270 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -1091,7 +1091,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM VECADDMUL(cloth1->verts[collpair->ap1].impulse, pimpulse, w1*2.0); VECADDMUL(cloth1->verts[collpair->ap2].impulse, pimpulse, w2*2.0); - VECADDMUL(cloth1->verts[collpair->ap3].impulse, pimpulse, w3*2.0);; + VECADDMUL(cloth1->verts[collpair->ap3].impulse, pimpulse, w3*2.0); cloth1->verts[collpair->ap1].impulse_count++; cloth1->verts[collpair->ap2].impulse_count++; cloth1->verts[collpair->ap3].impulse_count++; @@ -1487,8 +1487,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, sdis = clmd->coll_parms->distance_repel + epsilon2 + FLT_EPSILON; - /*apply a repulsion force, to help the solver along. - this is kindof crude, it only tests one vert of the triangle*/ + /* apply a repulsion force, to help the solver along. + * this is kindof crude, it only tests one vert of the triangle */ if (isect_ray_plane_v3(cloth->verts[collpair->ap1].tx, n2, collmd->current_xnew[collpair->bp1].co, collmd->current_xnew[collpair->bp2].co, collmd->current_xnew[collpair->bp3].co, &l, 0)) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 8d19322c0db..c342bbc917f 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -808,41 +808,65 @@ static void layerDefault_mcol(void *data, int count) static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { + /* 0: CD_MVERT */ {sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 1: CD_MSTICKY */ {sizeof(MSticky), "MSticky", 1, NULL, NULL, NULL, layerInterp_msticky, NULL, NULL}, + /* 2: CD_MDEFORMVERT */ {sizeof(MDeformVert), "MDeformVert", 1, NULL, layerCopy_mdeformvert, layerFree_mdeformvert, layerInterp_mdeformvert, NULL, NULL}, + /* 3: CD_MEDGE */ {sizeof(MEdge), "MEdge", 1, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 4: CD_MFACE */ {sizeof(MFace), "MFace", 1, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 5: CD_MTFACE */ {sizeof(MTFace), "MTFace", 1, "UVTex", layerCopy_tface, NULL, layerInterp_tface, layerSwap_tface, layerDefault_tface}, + /* 6: CD_MCOL */ /* 4 MCol structs per face */ {sizeof(MCol)*4, "MCol", 4, "Col", NULL, NULL, layerInterp_mcol, layerSwap_mcol, layerDefault_mcol}, + /* 7: CD_ORIGINDEX */ {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 8: CD_NORMAL */ /* 3 floats per normal vector */ {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 9: CD_FLAGS */ {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 10: CD_PROP_FLT */ {sizeof(MFloatProperty), "MFloatProperty",1,"Float",NULL,NULL,NULL,NULL}, + /* 11: CD_PROP_INT */ {sizeof(MIntProperty), "MIntProperty",1,"Int",NULL,NULL,NULL,NULL}, + /* 12: CD_PROP_STR */ {sizeof(MStringProperty), "MStringProperty",1,"String",NULL,NULL,NULL,NULL}, + /* 13: CD_ORIGSPACE */ {sizeof(OrigSpaceFace), "OrigSpaceFace", 1, "UVTex", layerCopy_origspace_face, NULL, layerInterp_origspace_face, layerSwap_origspace_face, layerDefault_origspace_face}, + /* 14: CD_ORCO */ {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 15: CD_MTEXPOLY */ {sizeof(MTexPoly), "MTexPoly", 1, "Face Texture", NULL, NULL, NULL, NULL, NULL}, + /* 16: CD_MLOOPUV */ {sizeof(MLoopUV), "MLoopUV", 1, "UV coord", NULL, NULL, layerInterp_mloopuv, NULL, NULL}, + /* 17: CD_MLOOPCOL */ {sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, layerInterp_mloopcol, NULL, layerDefault_mloopcol}, + /* 18: CD_TANGENT */ {sizeof(float)*4*4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 19: CD_MDISPS */ {sizeof(MDisps), "MDisps", 1, NULL, layerCopy_mdisps, layerFree_mdisps, layerInterp_mdisps, layerSwap_mdisps, NULL, layerRead_mdisps, layerWrite_mdisps, layerFilesize_mdisps, layerValidate_mdisps}, + /* 20: CD_WEIGHT_MCOL */ {sizeof(MCol)*4, "MCol", 4, "WeightCol", NULL, NULL, layerInterp_mcol, layerSwap_mcol, layerDefault_mcol}, - {sizeof(MCol)*4, "MCol", 4, "IDCol", NULL, NULL, layerInterp_mcol, + /* 21: CD_ID_MCOL */ + {sizeof(MCol)*4, "MCol", 4, "IDCol", NULL, NULL, layerInterp_mcol, layerSwap_mcol, layerDefault_mcol}, - {sizeof(MCol)*4, "MCol", 4, "TexturedCol", NULL, NULL, layerInterp_mcol, + /* 22: CD_TEXTURE_MCOL */ + {sizeof(MCol)*4, "MCol", 4, "TexturedCol", NULL, NULL, layerInterp_mcol, layerSwap_mcol, layerDefault_mcol}, + /* 23: CD_CLOTH_ORCO */ {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL} }; diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 9c916d517c5..70398594872 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -166,7 +166,7 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), unsigned int totve } if(BLI_edgehash_haskey(edge_hash, med->v1, med->v2)) { - PRINT(" edge %u: is a duplicate of, %u\n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, med->v1, med->v2))); + PRINT(" edge %u: is a duplicate of, %d\n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, med->v1, med->v2))); remove= do_fixes; } diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 25f824bba19..6ce80342dd6 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -359,6 +359,9 @@ NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker) #endif { strip->end = 10.0f; + /* quiet compiler warnings */ + (void)scene; + (void)speaker; } /* general settings */ diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index cdb509ab8e1..74f4830b86c 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -39,8 +39,10 @@ #include "BKE_sequencer.h" #include "BKE_scene.h" +#ifdef WITH_AUDASPACE // evil global ;-) static int sound_cfra; +#endif struct bSound* sound_new_file(struct Main *bmain, const char *filename) { @@ -760,5 +762,17 @@ void sound_seek_scene(struct bContext *UNUSED(C)) {} float sound_sync_scene(struct Scene *UNUSED(scene)) { return 0.0f; } int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; } int sound_read_sound_buffer(struct bSound* UNUSED(sound), float* UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; } +void sound_read_waveform(struct bSound* sound) { (void)sound; } +void sound_init_main(struct Main *bmain) { (void)bmain; } +void sound_set_cfra(int cfra) { (void)cfra; } +void sound_update_sequencer(struct Main* main, struct bSound* sound) { (void)main; (void)sound; } +void sound_update_scene(struct Scene* scene) { (void)scene; } +void sound_update_scene_sound(void* handle, struct bSound* sound) { (void)handle; (void)sound; } +void sound_update_scene_listener(struct Scene *scene) { (void)scene; } +void sound_update_fps(struct Scene *scene) { (void)scene; } +void sound_set_scene_sound_volume(void* handle, float volume, char animated) { (void)handle; (void)volume; (void)animated; } +void sound_set_scene_sound_pan(void* handle, float pan, char animated) { (void)handle; (void)pan; (void)animated; } +void sound_set_scene_volume(struct Scene *scene, float volume) { (void)scene; (void)volume; } +void sound_set_scene_sound_pitch(void* handle, float pitch, char animated) { (void)handle; (void)pitch; (void)animated; } #endif // WITH_AUDASPACE diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h index 1735848e774..f20cef9c3ea 100644 --- a/source/blender/blenlib/BLI_callbacks.h +++ b/source/blender/blenlib/BLI_callbacks.h @@ -42,6 +42,7 @@ struct ID; typedef enum { BLI_CB_EVT_RENDER_PRE, BLI_CB_EVT_RENDER_POST, + BLI_CB_EVT_RENDER_STATS, BLI_CB_EVT_LOAD_PRE, BLI_CB_EVT_LOAD_POST, BLI_CB_EVT_SAVE_PRE, diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 5b5de3ab3b6..8f025880a86 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -1968,7 +1968,7 @@ void resolve_tri_uv(float uv[2], const float st[2], const float st0[2], const fl void resolve_quad_uv(float uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2]) { const double signed_area= (st0[0]*st1[1] - st0[1]*st1[0]) + (st1[0]*st2[1] - st1[1]*st2[0]) + - (st2[0]*st3[1] - st2[1]*st3[0]) + (st3[0]*st0[1] - st3[1]*st0[0]); + (st2[0]*st3[1] - st2[1]*st3[0]) + (st3[0]*st0[1] - st3[1]*st0[0]); /* X is 2D cross product (determinant) A= (p0-p) X (p0-p3)*/ diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 5edf6e28d4c..3c79a77707a 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -820,7 +820,7 @@ void normalize_m4_m4(float rmat[][4], float mat[][4]) len= normalize_v3_v3(rmat[1], mat[1]); if(len!=0.0f) rmat[1][3]= mat[1][3] / len; len= normalize_v3_v3(rmat[2], mat[2]); - if(len!=0.0f) rmat[2][3]= mat[2][3] / len;; + if(len!=0.0f) rmat[2][3]= mat[2][3] / len; } void adjoint_m3_m3(float m1[][3], float m[][3]) diff --git a/source/blender/blenloader/BLO_sys_types.h b/source/blender/blenloader/BLO_sys_types.h index d56723ec1c5..2114fc34bf1 100644 --- a/source/blender/blenloader/BLO_sys_types.h +++ b/source/blender/blenloader/BLO_sys_types.h @@ -83,7 +83,7 @@ typedef unsigned long uintptr_t; #define _UINTPTR_T_DEFINED #endif -#elif defined(__linux__) || defined(__NetBSD__) +#elif defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) /* Linux-i386, Linux-Alpha, Linux-ppc */ #include diff --git a/source/blender/blenpluginapi/iff.h b/source/blender/blenpluginapi/iff.h index 77cdf889ea5..d29853f7d15 100644 --- a/source/blender/blenpluginapi/iff.h +++ b/source/blender/blenpluginapi/iff.h @@ -115,7 +115,7 @@ LIBIMPORT void IMB_rectcpy(struct ImBuf *dbuf, struct ImBuf *sbuf, LIBIMPORT void IMB_rectfill(struct ImBuf *drect, const float col[4]); LIBIMPORT void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2); -LIBIMPORT void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2); +LIBIMPORT void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2); LIBIMPORT void IMB_rectfill_alpha(struct ImBuf *drect, const float value); #endif /* IFF_H */ diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 8a0a39da558..4c20d1cf6c1 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -1,26 +1,26 @@ /* - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed. - * - * ***** END GPL LICENSE BLOCK ***** - */ +* $Id$ +* +* ***** BEGIN GPL LICENSE BLOCK ***** +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +* Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed. +* +* ***** END GPL LICENSE BLOCK ***** +*/ #include "GeometryExporter.h" #include "AnimationExporter.h" @@ -30,10 +30,10 @@ template void forEachObjectInScene(Scene *sce, Functor &f) { Base *base= (Base*) sce->base.first; - + while(base) { Object *ob = base->object; - + f(ob); base= base->next; @@ -61,7 +61,7 @@ void AnimationExporter::operator() (Object *ob) bool isMatAnim = false; //Export transform animations - if(ob->adt && ob->adt->action) + if(ob->adt && ob->adt->action) { fcu = (FCurve*)ob->adt->action->curves.first; @@ -72,21 +72,21 @@ void AnimationExporter::operator() (Object *ob) for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) write_bone_animation_matrix(ob, bone); } - + while (fcu) { //for armature animations as objects if ( ob->type == OB_ARMATURE ) transformName = fcu->rna_path; else transformName = extract_transform_name( fcu->rna_path ); - + if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)|| (!strcmp(transformName, "rotation_quaternion"))) dae_animation(ob ,fcu, transformName, false); fcu = fcu->next; } - + } //Export Lamp parameter animations @@ -94,8 +94,8 @@ void AnimationExporter::operator() (Object *ob) { fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first); while (fcu) { - transformName = extract_transform_name( fcu->rna_path ); - + transformName = extract_transform_name( fcu->rna_path ); + if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))|| (!strcmp(transformName, "spot_blend"))|| (!strcmp(transformName, "distance")) ) dae_animation(ob , fcu, transformName, true ); @@ -108,8 +108,8 @@ void AnimationExporter::operator() (Object *ob) { fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); while (fcu) { - transformName = extract_transform_name( fcu->rna_path ); - + transformName = extract_transform_name( fcu->rna_path ); + if ((!strcmp(transformName, "lens"))|| (!strcmp(transformName, "ortho_scale"))|| (!strcmp(transformName, "clip_end"))||(!strcmp(transformName, "clip_start"))) @@ -129,7 +129,7 @@ void AnimationExporter::operator() (Object *ob) fcu = (FCurve*)ma->adt->action->curves.first; while (fcu) { transformName = extract_transform_name( fcu->rna_path ); - + if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color")) ||(!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha"))|| (!strcmp(transformName, "ior"))) @@ -137,384 +137,384 @@ void AnimationExporter::operator() (Object *ob) fcu = fcu->next; } } - + } } - //euler sources from quternion sources - float * AnimationExporter::get_eul_source_for_quat(Object *ob ) +//euler sources from quternion sources +float * AnimationExporter::get_eul_source_for_quat(Object *ob ) +{ + FCurve *fcu = (FCurve*)ob->adt->action->curves.first; + const int keys = fcu->totvert; + float *quat = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 4, "quat output source values"); + float *eul = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values"); + float temp_quat[4]; + float temp_eul[3]; + while(fcu) { - FCurve *fcu = (FCurve*)ob->adt->action->curves.first; - const int keys = fcu->totvert; - float *quat = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 4, "quat output source values"); - float *eul = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values"); - float temp_quat[4]; - float temp_eul[3]; - while(fcu) - { - char * transformName = extract_transform_name( fcu->rna_path ); - - if( !strcmp(transformName, "rotation_quaternion") ) { - for ( int i = 0 ; i < fcu->totvert ; i++){ - *(quat + ( i * 4 ) + fcu->array_index) = fcu->bezt[i].vec[1][1]; - } - } - fcu = fcu->next; + char * transformName = extract_transform_name( fcu->rna_path ); + + if( !strcmp(transformName, "rotation_quaternion") ) { + for ( int i = 0 ; i < fcu->totvert ; i++){ + *(quat + ( i * 4 ) + fcu->array_index) = fcu->bezt[i].vec[1][1]; } - - for ( int i = 0 ; i < keys ; i++){ - for ( int j = 0;j<4;j++) - temp_quat[j] = quat[(i*4)+j]; - - quat_to_eul(temp_eul,temp_quat); - - for (int k = 0;k<3;k++) - eul[i*3 + k] = temp_eul[k]; - - } - MEM_freeN(quat); - return eul; - - } - - //Get proper name for bones - std::string AnimationExporter::getObjectBoneName( Object* ob,const FCurve* fcu ) - { - //hard-way to derive the bone name from rna_path. Must find more compact method - std::string rna_path = std::string(fcu->rna_path); - - char* boneName = strtok((char *)rna_path.c_str(), "\""); - boneName = strtok(NULL,"\""); - - if( boneName != NULL ) - return /*id_name(ob) + "_" +*/ std::string(boneName); - else - return id_name(ob); - } - - //convert f-curves to animation curves and write - void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformName , bool is_param, Material * ma ) - { - const char *axis_name = NULL; - char anim_id[200]; - - bool has_tangents = false; - bool quatRotation = false; - - if ( !strcmp(transformName, "rotation_quaternion") ) - { - fprintf(stderr, "quaternion rotation curves are not supported. rotation curve will not be exported\n"); - quatRotation = true; - return; } - - //axis names for colors - else if ( !strcmp(transformName, "color")||!strcmp(transformName, "specular_color")||!strcmp(transformName, "diffuse_color")|| - (!strcmp(transformName, "alpha"))) - { - const char *axis_names[] = {"R", "G", "B"}; - if (fcu->array_index < 3) + fcu = fcu->next; + } + + for ( int i = 0 ; i < keys ; i++){ + for ( int j = 0;j<4;j++) + temp_quat[j] = quat[(i*4)+j]; + + quat_to_eul(temp_eul,temp_quat); + + for (int k = 0;k<3;k++) + eul[i*3 + k] = temp_eul[k]; + + } + MEM_freeN(quat); + return eul; + +} + +//Get proper name for bones +std::string AnimationExporter::getObjectBoneName( Object* ob,const FCurve* fcu ) +{ + //hard-way to derive the bone name from rna_path. Must find more compact method + std::string rna_path = std::string(fcu->rna_path); + + char* boneName = strtok((char *)rna_path.c_str(), "\""); + boneName = strtok(NULL,"\""); + + if( boneName != NULL ) + return /*id_name(ob) + "_" +*/ std::string(boneName); + else + return id_name(ob); +} + +//convert f-curves to animation curves and write +void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformName , bool is_param, Material * ma ) +{ + const char *axis_name = NULL; + char anim_id[200]; + + bool has_tangents = false; + bool quatRotation = false; + + if ( !strcmp(transformName, "rotation_quaternion") ) + { + fprintf(stderr, "quaternion rotation curves are not supported. rotation curve will not be exported\n"); + quatRotation = true; + return; + } + + //axis names for colors + else if ( !strcmp(transformName, "color")||!strcmp(transformName, "specular_color")||!strcmp(transformName, "diffuse_color")|| + (!strcmp(transformName, "alpha"))) + { + const char *axis_names[] = {"R", "G", "B"}; + if (fcu->array_index < 3) axis_name = axis_names[fcu->array_index]; - } - - //axis names for transforms - else if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || - (!strcmp(transformName, "rotation_euler"))||(!strcmp(transformName, "rotation_quaternion"))) - { - const char *axis_names[] = {"X", "Y", "Z"}; - if (fcu->array_index < 3) - axis_name = axis_names[fcu->array_index]; - } - - //no axis name. single parameter. - else{ - axis_name = ""; - } - - std::string ob_name = std::string("null"); - - //Create anim Id - if (ob->type == OB_ARMATURE) - { - ob_name = getObjectBoneName( ob , fcu); - BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s.%s", (char*)translate_id(ob_name).c_str(), - transformName, axis_name); - } - else - { - if (ma) - ob_name = id_name(ob) + "_material"; - else - ob_name = id_name(ob); - BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), - fcu->rna_path, axis_name); - } - - openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); - - // create input source - std::string input_id = create_source_from_fcurve(COLLADASW::InputSemantic::INPUT, fcu, anim_id, axis_name); - - // create output source - std::string output_id ; - - //quat rotations are skipped for now, because of complications with determining axis. - if(quatRotation) - { - float * eul = get_eul_source_for_quat(ob); - float * eul_axis = (float*)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values"); - for ( int i = 0 ; i< fcu->totvert ; i++) - eul_axis[i] = eul[i*3 + fcu->array_index]; - output_id= create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis , fcu->totvert, quatRotation, anim_id, axis_name); - MEM_freeN(eul); - MEM_freeN(eul_axis); - } - else - { - output_id= create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name); - } - // create interpolations source - std::string interpolation_id = create_interpolation_source(fcu, anim_id, axis_name, &has_tangents); - - // handle tangents (if required) - std::string intangent_id; - std::string outtangent_id; - - if (has_tangents) { - // create in_tangent source - intangent_id = create_source_from_fcurve(COLLADASW::InputSemantic::IN_TANGENT, fcu, anim_id, axis_name); - - // create out_tangent source - outtangent_id = create_source_from_fcurve(COLLADASW::InputSemantic::OUT_TANGENT, fcu, anim_id, axis_name); - } - - std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; - COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); - std::string empty; - sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); - sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); - - // this input is required - sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); - - if (has_tangents) { - sampler.addInput(COLLADASW::InputSemantic::IN_TANGENT, COLLADABU::URI(empty, intangent_id)); - sampler.addInput(COLLADASW::InputSemantic::OUT_TANGENT, COLLADABU::URI(empty, outtangent_id)); - } - - addSampler(sampler); - - std::string target ; - - if ( !is_param ) - target = translate_id(ob_name) - + "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true); - else - { - if ( ob->type == OB_LAMP ) - target = get_light_id(ob) - + "/" + get_light_param_sid(fcu->rna_path, -1, axis_name, true); - - if ( ob->type == OB_CAMERA ) - target = get_camera_id(ob) - + "/" + get_camera_param_sid(fcu->rna_path, -1, axis_name, true); - - if( ma ) - target = translate_id(id_name(ma)) + "-effect" - +"/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true); - } - addChannel(COLLADABU::URI(empty, sampler_id), target); - - closeAnimation(); } - - - //write bone animations in transform matrix sources - void AnimationExporter::write_bone_animation_matrix(Object *ob_arm, Bone *bone) + //axis names for transforms + else if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || + (!strcmp(transformName, "rotation_euler"))||(!strcmp(transformName, "rotation_quaternion"))) { - if (!ob_arm->adt) - return; - - //This will only export animations of bones in deform group. - /*if(!is_bone_deform_group(bone)) - return;*/ - - sample_and_write_bone_animation_matrix(ob_arm, bone); - - for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) - write_bone_animation_matrix(ob_arm, child); + const char *axis_names[] = {"X", "Y", "Z"}; + if (fcu->array_index < 3) + axis_name = axis_names[fcu->array_index]; } - bool AnimationExporter::is_bone_deform_group(Bone * bone) + //no axis name. single parameter. + else{ + axis_name = ""; + } + + std::string ob_name = std::string("null"); + + //Create anim Id + if (ob->type == OB_ARMATURE) { - bool is_def; - //Check if current bone is deform - if((bone->flag & BONE_NO_DEFORM) == 0 ) return true; - //Check child bones - else - { - for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next){ - //loop through all the children until deform bone is found, and then return - is_def = is_bone_deform_group(child); - if (is_def) return true; - } - } - //no deform bone found in children also - return false; + ob_name = getObjectBoneName( ob , fcu); + BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s.%s", (char*)translate_id(ob_name).c_str(), + transformName, axis_name); + } + else + { + if (ma) + ob_name = id_name(ob) + "_material"; + else + ob_name = id_name(ob); + BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), + fcu->rna_path, axis_name); } - void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, Bone *bone) + openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); + + // create input source + std::string input_id = create_source_from_fcurve(COLLADASW::InputSemantic::INPUT, fcu, anim_id, axis_name); + + // create output source + std::string output_id ; + + //quat rotations are skipped for now, because of complications with determining axis. + if(quatRotation) { - bArmature *arm = (bArmature*)ob_arm->data; - int flag = arm->flag; - std::vector fra; - //char prefix[256]; + float * eul = get_eul_source_for_quat(ob); + float * eul_axis = (float*)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values"); + for ( int i = 0 ; i< fcu->totvert ; i++) + eul_axis[i] = eul[i*3 + fcu->array_index]; + output_id= create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis , fcu->totvert, quatRotation, anim_id, axis_name); + MEM_freeN(eul); + MEM_freeN(eul_axis); + } + else + { + output_id= create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name); + } + // create interpolations source + std::string interpolation_id = create_interpolation_source(fcu, anim_id, axis_name, &has_tangents); - FCurve* fcu = (FCurve*)ob_arm->adt->action->curves.first; - while(fcu) - { - std::string bone_name = getObjectBoneName(ob_arm,fcu); - int val = BLI_strcasecmp((char*)bone_name.c_str(),bone->name); - if(val==0) break; - fcu = fcu->next; + // handle tangents (if required) + std::string intangent_id; + std::string outtangent_id; + + if (has_tangents) { + // create in_tangent source + intangent_id = create_source_from_fcurve(COLLADASW::InputSemantic::IN_TANGENT, fcu, anim_id, axis_name); + + // create out_tangent source + outtangent_id = create_source_from_fcurve(COLLADASW::InputSemantic::OUT_TANGENT, fcu, anim_id, axis_name); + } + + std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; + COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); + std::string empty; + sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); + sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); + + // this input is required + sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); + + if (has_tangents) { + sampler.addInput(COLLADASW::InputSemantic::IN_TANGENT, COLLADABU::URI(empty, intangent_id)); + sampler.addInput(COLLADASW::InputSemantic::OUT_TANGENT, COLLADABU::URI(empty, outtangent_id)); + } + + addSampler(sampler); + + std::string target ; + + if ( !is_param ) + target = translate_id(ob_name) + + "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true); + else + { + if ( ob->type == OB_LAMP ) + target = get_light_id(ob) + + "/" + get_light_param_sid(fcu->rna_path, -1, axis_name, true); + + if ( ob->type == OB_CAMERA ) + target = get_camera_id(ob) + + "/" + get_camera_param_sid(fcu->rna_path, -1, axis_name, true); + + if( ma ) + target = translate_id(id_name(ma)) + "-effect" + +"/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true); + } + addChannel(COLLADABU::URI(empty, sampler_id), target); + + closeAnimation(); +} + + + +//write bone animations in transform matrix sources +void AnimationExporter::write_bone_animation_matrix(Object *ob_arm, Bone *bone) +{ + if (!ob_arm->adt) + return; + + //This will only export animations of bones in deform group. + /*if(!is_bone_deform_group(bone)) + return;*/ + + sample_and_write_bone_animation_matrix(ob_arm, bone); + + for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) + write_bone_animation_matrix(ob_arm, child); +} + +bool AnimationExporter::is_bone_deform_group(Bone * bone) +{ + bool is_def; + //Check if current bone is deform + if((bone->flag & BONE_NO_DEFORM) == 0 ) return true; + //Check child bones + else + { + for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next){ + //loop through all the children until deform bone is found, and then return + is_def = is_bone_deform_group(child); + if (is_def) return true; } + } + //no deform bone found in children also + return false; +} - if(!(fcu)) return; - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); - if (!pchan) - return; - - find_frames(ob_arm, fra); +void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, Bone *bone) +{ + bArmature *arm = (bArmature*)ob_arm->data; + int flag = arm->flag; + std::vector fra; + //char prefix[256]; - if (flag & ARM_RESTPOS) { - arm->flag &= ~ARM_RESTPOS; - where_is_pose(scene, ob_arm); - } + FCurve* fcu = (FCurve*)ob_arm->adt->action->curves.first; + while(fcu) + { + std::string bone_name = getObjectBoneName(ob_arm,fcu); + int val = BLI_strcasecmp((char*)bone_name.c_str(),bone->name); + if(val==0) break; + fcu = fcu->next; + } - if (fra.size()) { - dae_baked_animation(fra ,ob_arm, bone ); - } + if(!(fcu)) return; + bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); + if (!pchan) + return; - if (flag & ARM_RESTPOS) - arm->flag = flag; + find_frames(ob_arm, fra); + + if (flag & ARM_RESTPOS) { + arm->flag &= ~ARM_RESTPOS; where_is_pose(scene, ob_arm); } - void AnimationExporter::dae_baked_animation(std::vector &fra, Object *ob_arm , Bone *bone) - { - std::string ob_name = id_name(ob_arm); - std::string bone_name = bone->name; - char anim_id[200]; - - if (!fra.size()) - return; - - BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), - (char*)translate_id(bone_name).c_str(), "pose_matrix"); - - openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); - - // create input source - std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, fra, false, anim_id, ""); - - // create output source - std::string output_id; - output_id = create_4x4_source( fra, ob_arm , bone , anim_id); - - // create interpolations source - std::string interpolation_id = fake_interpolation_source(fra.size(), anim_id, ""); - - std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; - COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); - std::string empty; - sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); - sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); - - // TODO create in/out tangents source - - // this input is required - sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); - - addSampler(sampler); - - std::string target = translate_id(bone_name) + "/transform"; - addChannel(COLLADABU::URI(empty, sampler_id), target); - - closeAnimation(); + if (fra.size()) { + dae_baked_animation(fra ,ob_arm, bone ); } - // dae_bone_animation -> add_bone_animation - // (blend this into dae_bone_animation) - void AnimationExporter::dae_bone_animation(std::vector &fra, float *values, int tm_type, int axis, std::string ob_name, std::string bone_name) - { - const char *axis_names[] = {"X", "Y", "Z"}; - const char *axis_name = NULL; - char anim_id[200]; - bool is_rot = tm_type == 0; - - if (!fra.size()) - return; + if (flag & ARM_RESTPOS) + arm->flag = flag; + where_is_pose(scene, ob_arm); +} - char rna_path[200]; - BLI_snprintf(rna_path, sizeof(rna_path), "pose.bones[\"%s\"].%s", bone_name.c_str(), - tm_type == 0 ? "rotation_quaternion" : (tm_type == 1 ? "scale" : "location")); +void AnimationExporter::dae_baked_animation(std::vector &fra, Object *ob_arm , Bone *bone) +{ + std::string ob_name = id_name(ob_arm); + std::string bone_name = bone->name; + char anim_id[200]; - if (axis > -1) - axis_name = axis_names[axis]; - - std::string transform_sid = get_transform_sid(NULL, tm_type, axis_name, false); - - BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), - (char*)translate_id(bone_name).c_str(), (char*)transform_sid.c_str()); + if (!fra.size()) + return; - openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); + BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), + (char*)translate_id(bone_name).c_str(), "pose_matrix"); - // create input source - std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, fra, is_rot, anim_id, axis_name); + openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); - // create output source - std::string output_id; - if (axis == -1) - output_id = create_xyz_source(values, fra.size(), anim_id); - else - output_id = create_source_from_array(COLLADASW::InputSemantic::OUTPUT, values, fra.size(), is_rot, anim_id, axis_name); + // create input source + std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, fra, false, anim_id, ""); - // create interpolations source - std::string interpolation_id = fake_interpolation_source(fra.size(), anim_id, axis_name); + // create output source + std::string output_id; + output_id = create_4x4_source( fra, ob_arm , bone , anim_id); - std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; - COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); - std::string empty; - sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); - sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); + // create interpolations source + std::string interpolation_id = fake_interpolation_source(fra.size(), anim_id, ""); - // TODO create in/out tangents source + std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; + COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); + std::string empty; + sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); + sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); - // this input is required - sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); + // TODO create in/out tangents source - addSampler(sampler); + // this input is required + sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); - std::string target = translate_id(ob_name + "_" + bone_name) + "/" + transform_sid; - addChannel(COLLADABU::URI(empty, sampler_id), target); + addSampler(sampler); - closeAnimation(); - } + std::string target = translate_id(bone_name) + "/transform"; + addChannel(COLLADABU::URI(empty, sampler_id), target); - float AnimationExporter::convert_time(float frame) - { - return FRA2TIME(frame); - } + closeAnimation(); +} - float AnimationExporter::convert_angle(float angle) - { - return COLLADABU::Math::Utils::radToDegF(angle); - } +// dae_bone_animation -> add_bone_animation +// (blend this into dae_bone_animation) +void AnimationExporter::dae_bone_animation(std::vector &fra, float *values, int tm_type, int axis, std::string ob_name, std::string bone_name) +{ + const char *axis_names[] = {"X", "Y", "Z"}; + const char *axis_name = NULL; + char anim_id[200]; + bool is_rot = tm_type == 0; - std::string AnimationExporter::get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic) - { - switch(semantic) { + if (!fra.size()) + return; + + char rna_path[200]; + BLI_snprintf(rna_path, sizeof(rna_path), "pose.bones[\"%s\"].%s", bone_name.c_str(), + tm_type == 0 ? "rotation_quaternion" : (tm_type == 1 ? "scale" : "location")); + + if (axis > -1) + axis_name = axis_names[axis]; + + std::string transform_sid = get_transform_sid(NULL, tm_type, axis_name, false); + + BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), + (char*)translate_id(bone_name).c_str(), (char*)transform_sid.c_str()); + + openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); + + // create input source + std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, fra, is_rot, anim_id, axis_name); + + // create output source + std::string output_id; + if (axis == -1) + output_id = create_xyz_source(values, fra.size(), anim_id); + else + output_id = create_source_from_array(COLLADASW::InputSemantic::OUTPUT, values, fra.size(), is_rot, anim_id, axis_name); + + // create interpolations source + std::string interpolation_id = fake_interpolation_source(fra.size(), anim_id, axis_name); + + std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; + COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); + std::string empty; + sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); + sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); + + // TODO create in/out tangents source + + // this input is required + sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); + + addSampler(sampler); + + std::string target = translate_id(ob_name + "_" + bone_name) + "/" + transform_sid; + addChannel(COLLADABU::URI(empty, sampler_id), target); + + closeAnimation(); +} + +float AnimationExporter::convert_time(float frame) +{ + return FRA2TIME(frame); +} + +float AnimationExporter::convert_angle(float angle) +{ + return COLLADABU::Math::Utils::radToDegF(angle); +} + +std::string AnimationExporter::get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic) +{ + switch(semantic) { case COLLADASW::InputSemantic::INPUT: return INPUT_SOURCE_ID_SUFFIX; case COLLADASW::InputSemantic::OUTPUT: @@ -527,14 +527,14 @@ void AnimationExporter::operator() (Object *ob) return OUTTANGENT_SOURCE_ID_SUFFIX; default: break; - } - return ""; } + return ""; +} - void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param, - COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform) - { - switch(semantic) { +void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param, + COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform) +{ + switch(semantic) { case COLLADASW::InputSemantic::INPUT: param.push_back("TIME"); break; @@ -547,14 +547,14 @@ void AnimationExporter::operator() (Object *ob) param.push_back(axis); } else - if ( transform ) - { - param.push_back("TRANSFORM"); - }else{ //assumes if axis isn't specified all axises are added - param.push_back("X"); - param.push_back("Y"); - param.push_back("Z"); - } + if ( transform ) + { + param.push_back("TRANSFORM"); + }else{ //assumes if axis isn't specified all axises are added + param.push_back("X"); + param.push_back("Y"); + param.push_back("Z"); + } } break; case COLLADASW::InputSemantic::IN_TANGENT: @@ -564,12 +564,12 @@ void AnimationExporter::operator() (Object *ob) break; default: break; - } } +} - void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool rotation, float *values, int *length) - { - switch (semantic) { +void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool rotation, float *values, int *length) +{ + switch (semantic) { case COLLADASW::InputSemantic::INPUT: *length = 1; values[0] = convert_time(bezt->vec[1][0]); @@ -583,9 +583,9 @@ void AnimationExporter::operator() (Object *ob) values[0] = bezt->vec[1][1]; } break; - + case COLLADASW::InputSemantic::IN_TANGENT: - *length = 2; + *length = 2; values[0] = convert_time(bezt->vec[0][0]); if (bezt->ipo != BEZT_IPO_BEZ) { // We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data @@ -598,7 +598,7 @@ void AnimationExporter::operator() (Object *ob) values[1] = bezt->vec[0][1]; } break; - + case COLLADASW::InputSemantic::OUT_TANGENT: *length = 2; values[0] = convert_time(bezt->vec[2][0]); @@ -617,283 +617,283 @@ void AnimationExporter::operator() (Object *ob) default: *length = 0; break; - } } +} - std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemantic::Semantics semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name) - { - std::string source_id = anim_id + get_semantic_suffix(semantic); +std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemantic::Semantics semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name) +{ + std::string source_id = anim_id + get_semantic_suffix(semantic); - //bool is_rotation = !strcmp(fcu->rna_path, "rotation"); - bool is_angle = false; - - if (strstr(fcu->rna_path, "rotation")) is_angle = true; - - COLLADASW::FloatSourceF source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(fcu->totvert); - - switch (semantic) { + //bool is_rotation = !strcmp(fcu->rna_path, "rotation"); + bool is_angle = false; + + if (strstr(fcu->rna_path, "rotation")) is_angle = true; + + COLLADASW::FloatSourceF source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(fcu->totvert); + + switch (semantic) { case COLLADASW::InputSemantic::INPUT: case COLLADASW::InputSemantic::OUTPUT: - source.setAccessorStride(1); + source.setAccessorStride(1); break; case COLLADASW::InputSemantic::IN_TANGENT: case COLLADASW::InputSemantic::OUT_TANGENT: - source.setAccessorStride(2); + source.setAccessorStride(2); break; - } - - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, is_angle, axis_name, false); - - source.prepareToAppendValues(); - - for (unsigned int i = 0; i < fcu->totvert; i++) { - float values[3]; // be careful! - int length = 0; - get_source_values(&fcu->bezt[i], semantic, is_angle, values, &length); - for (int j = 0; j < length; j++) - source.appendValues(values[j]); - } - - source.finish(); - - return source_id; } - //Currently called only to get OUTPUT source values ( if rotation and hence the axis is also specified ) - std::string AnimationExporter::create_source_from_array(COLLADASW::InputSemantic::Semantics semantic, float *v, int tot, bool is_rot, const std::string& anim_id, const char *axis_name) - { - std::string source_id = anim_id + get_semantic_suffix(semantic); - COLLADASW::FloatSourceF source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(tot); - source.setAccessorStride(1); - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, is_rot, axis_name, false); + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + add_source_parameters(param, semantic, is_angle, axis_name, false); - source.prepareToAppendValues(); + source.prepareToAppendValues(); - for (int i = 0; i < tot; i++) { - float val = v[i]; - ////if (semantic == COLLADASW::InputSemantic::INPUT) - // val = convert_time(val); - //else - if (is_rot) - val *= 180.0f / M_PI; - source.appendValues(val); - } - - source.finish(); - - return source_id; + for (unsigned int i = 0; i < fcu->totvert; i++) { + float values[3]; // be careful! + int length = 0; + get_source_values(&fcu->bezt[i], semantic, is_angle, values, &length); + for (int j = 0; j < length; j++) + source.appendValues(values[j]); } + + source.finish(); + + return source_id; +} + +//Currently called only to get OUTPUT source values ( if rotation and hence the axis is also specified ) +std::string AnimationExporter::create_source_from_array(COLLADASW::InputSemantic::Semantics semantic, float *v, int tot, bool is_rot, const std::string& anim_id, const char *axis_name) +{ + std::string source_id = anim_id + get_semantic_suffix(semantic); + + COLLADASW::FloatSourceF source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(tot); + source.setAccessorStride(1); + + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + add_source_parameters(param, semantic, is_rot, axis_name, false); + + source.prepareToAppendValues(); + + for (int i = 0; i < tot; i++) { + float val = v[i]; + ////if (semantic == COLLADASW::InputSemantic::INPUT) + // val = convert_time(val); + //else + if (is_rot) + val *= 180.0f / M_PI; + source.appendValues(val); + } + + source.finish(); + + return source_id; +} // only used for sources with INPUT semantic - std::string AnimationExporter::create_source_from_vector(COLLADASW::InputSemantic::Semantics semantic, std::vector &fra, bool is_rot, const std::string& anim_id, const char *axis_name) - { - std::string source_id = anim_id + get_semantic_suffix(semantic); +std::string AnimationExporter::create_source_from_vector(COLLADASW::InputSemantic::Semantics semantic, std::vector &fra, bool is_rot, const std::string& anim_id, const char *axis_name) +{ + std::string source_id = anim_id + get_semantic_suffix(semantic); - COLLADASW::FloatSourceF source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(fra.size()); - source.setAccessorStride(1); - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, is_rot, axis_name, false); + COLLADASW::FloatSourceF source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(fra.size()); + source.setAccessorStride(1); - source.prepareToAppendValues(); + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + add_source_parameters(param, semantic, is_rot, axis_name, false); - std::vector::iterator it; - for (it = fra.begin(); it != fra.end(); it++) { - float val = *it; - //if (semantic == COLLADASW::InputSemantic::INPUT) - val = convert_time(val); - /*else if (is_rot) - val = convert_angle(val);*/ - source.appendValues(val); - } + source.prepareToAppendValues(); - source.finish(); - - return source_id; + std::vector::iterator it; + for (it = fra.begin(); it != fra.end(); it++) { + float val = *it; + //if (semantic == COLLADASW::InputSemantic::INPUT) + val = convert_time(val); + /*else if (is_rot) + val = convert_angle(val);*/ + source.appendValues(val); } - std::string AnimationExporter::create_4x4_source(std::vector &frames , Object * ob_arm, Bone *bone , const std::string& anim_id) - { - COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT; - std::string source_id = anim_id + get_semantic_suffix(semantic); + source.finish(); - COLLADASW::Float4x4Source source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(frames.size()); - source.setAccessorStride(16); - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, false, NULL, true); + return source_id; +} - source.prepareToAppendValues(); - - bPoseChannel *parchan = NULL; - bPoseChannel *pchan = NULL; - bPose *pose = ob_arm->pose; +std::string AnimationExporter::create_4x4_source(std::vector &frames , Object * ob_arm, Bone *bone , const std::string& anim_id) +{ + COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT; + std::string source_id = anim_id + get_semantic_suffix(semantic); - pchan = get_pose_channel(pose, bone->name); + COLLADASW::Float4x4Source source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(frames.size()); + source.setAccessorStride(16); - if (!pchan) - return ""; + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + add_source_parameters(param, semantic, false, NULL, true); - parchan = pchan->parent; + source.prepareToAppendValues(); - enable_fcurves(ob_arm->adt->action, bone->name); + bPoseChannel *parchan = NULL; + bPoseChannel *pchan = NULL; + bPose *pose = ob_arm->pose; - std::vector::iterator it; - int j = 0; - for (it = frames.begin(); it != frames.end(); it++) { - float mat[4][4], ipar[4][4]; + pchan = get_pose_channel(pose, bone->name); - float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); + if (!pchan) + return ""; - BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); - where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); + parchan = pchan->parent; - // compute bone local mat - if (bone->parent) { - invert_m4_m4(ipar, parchan->pose_mat); - mul_m4_m4m4(mat, pchan->pose_mat, ipar); - } - else - copy_m4_m4(mat, pchan->pose_mat); - UnitConverter converter; + enable_fcurves(ob_arm->adt->action, bone->name); - float outmat[4][4]; - converter.mat4_to_dae(outmat,mat); + std::vector::iterator it; + int j = 0; + for (it = frames.begin(); it != frames.end(); it++) { + float mat[4][4], ipar[4][4]; + float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); - source.appendValues(outmat); - + BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); + where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); - j++; + // compute bone local mat + if (bone->parent) { + invert_m4_m4(ipar, parchan->pose_mat); + mul_m4_m4m4(mat, pchan->pose_mat, ipar); } + else + copy_m4_m4(mat, pchan->pose_mat); + UnitConverter converter; - enable_fcurves(ob_arm->adt->action, NULL); + float outmat[4][4]; + converter.mat4_to_dae(outmat,mat); - source.finish(); - return source_id; - } - // only used for sources with OUTPUT semantic ( locations and scale) - std::string AnimationExporter::create_xyz_source(float *v, int tot, const std::string& anim_id) - { - COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT; - std::string source_id = anim_id + get_semantic_suffix(semantic); + source.appendValues(outmat); - COLLADASW::FloatSourceF source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(tot); - source.setAccessorStride(3); - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, false, NULL, false); - source.prepareToAppendValues(); - - for (int i = 0; i < tot; i++) { - source.appendValues(*v, *(v + 1), *(v + 2)); - v += 3; - } - - source.finish(); - - return source_id; + j++; } - std::string AnimationExporter::create_interpolation_source(FCurve *fcu, const std::string& anim_id, const char *axis_name, bool *has_tangents) - { - std::string source_id = anim_id + get_semantic_suffix(COLLADASW::InputSemantic::INTERPOLATION); + enable_fcurves(ob_arm->adt->action, NULL); - COLLADASW::NameSource source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(fcu->totvert); - source.setAccessorStride(1); - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("INTERPOLATION"); + source.finish(); - source.prepareToAppendValues(); + return source_id; +} +// only used for sources with OUTPUT semantic ( locations and scale) +std::string AnimationExporter::create_xyz_source(float *v, int tot, const std::string& anim_id) +{ + COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT; + std::string source_id = anim_id + get_semantic_suffix(semantic); - *has_tangents = false; + COLLADASW::FloatSourceF source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(tot); + source.setAccessorStride(3); - for (unsigned int i = 0; i < fcu->totvert; i++) { - if (fcu->bezt[i].ipo==BEZT_IPO_BEZ) { - source.appendValues(BEZIER_NAME); - *has_tangents = true; - } else if (fcu->bezt[i].ipo==BEZT_IPO_CONST) { - source.appendValues(STEP_NAME); - } else { // BEZT_IPO_LIN - source.appendValues(LINEAR_NAME); - } - } - // unsupported? -- HERMITE, CARDINAL, BSPLINE, NURBS + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + add_source_parameters(param, semantic, false, NULL, false); - source.finish(); + source.prepareToAppendValues(); - return source_id; + for (int i = 0; i < tot; i++) { + source.appendValues(*v, *(v + 1), *(v + 2)); + v += 3; } - std::string AnimationExporter::fake_interpolation_source(int tot, const std::string& anim_id, const char *axis_name) - { - std::string source_id = anim_id + get_semantic_suffix(COLLADASW::InputSemantic::INTERPOLATION); + source.finish(); - COLLADASW::NameSource source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(tot); - source.setAccessorStride(1); - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("INTERPOLATION"); + return source_id; +} - source.prepareToAppendValues(); +std::string AnimationExporter::create_interpolation_source(FCurve *fcu, const std::string& anim_id, const char *axis_name, bool *has_tangents) +{ + std::string source_id = anim_id + get_semantic_suffix(COLLADASW::InputSemantic::INTERPOLATION); - for (int i = 0; i < tot; i++) { + COLLADASW::NameSource source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(fcu->totvert); + source.setAccessorStride(1); + + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + param.push_back("INTERPOLATION"); + + source.prepareToAppendValues(); + + *has_tangents = false; + + for (unsigned int i = 0; i < fcu->totvert; i++) { + if (fcu->bezt[i].ipo==BEZT_IPO_BEZ) { + source.appendValues(BEZIER_NAME); + *has_tangents = true; + } else if (fcu->bezt[i].ipo==BEZT_IPO_CONST) { + source.appendValues(STEP_NAME); + } else { // BEZT_IPO_LIN source.appendValues(LINEAR_NAME); } + } + // unsupported? -- HERMITE, CARDINAL, BSPLINE, NURBS - source.finish(); + source.finish(); - return source_id; + return source_id; +} + +std::string AnimationExporter::fake_interpolation_source(int tot, const std::string& anim_id, const char *axis_name) +{ + std::string source_id = anim_id + get_semantic_suffix(COLLADASW::InputSemantic::INTERPOLATION); + + COLLADASW::NameSource source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(tot); + source.setAccessorStride(1); + + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + param.push_back("INTERPOLATION"); + + source.prepareToAppendValues(); + + for (int i = 0; i < tot; i++) { + source.appendValues(LINEAR_NAME); } - std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) - { - std::string tm_name; - // when given rna_path, determine tm_type from it - if (rna_path) { - char *name = extract_transform_name(rna_path); + source.finish(); - if (!strcmp(name, "color")) - tm_type = 1; - else if (!strcmp(name, "spot_size")) - tm_type = 2; - else if (!strcmp(name, "spot_blend")) - tm_type = 3; - else if (!strcmp(name, "distance")) - tm_type = 4; - else - tm_type = -1; - } + return source_id; +} - switch (tm_type) { +std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) +{ + std::string tm_name; + // when given rna_path, determine tm_type from it + if (rna_path) { + char *name = extract_transform_name(rna_path); + + if (!strcmp(name, "color")) + tm_type = 1; + else if (!strcmp(name, "spot_size")) + tm_type = 2; + else if (!strcmp(name, "spot_blend")) + tm_type = 3; + else if (!strcmp(name, "distance")) + tm_type = 4; + else + tm_type = -1; + } + + switch (tm_type) { case 1: tm_name = "color"; break; @@ -906,43 +906,43 @@ void AnimationExporter::operator() (Object *ob) case 4: tm_name = "blender/blender_dist"; break; - + default: tm_name = ""; break; - } - - if (tm_name.size()) { - if (axis_name != "") - return tm_name + "." + std::string(axis_name); - else - return tm_name; - } - - return std::string(""); } - - std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) - { - std::string tm_name; - // when given rna_path, determine tm_type from it - if (rna_path) { - char *name = extract_transform_name(rna_path); - if (!strcmp(name, "lens")) - tm_type = 0; - else if (!strcmp(name, "ortho_scale")) - tm_type = 1; - else if (!strcmp(name, "clip_end")) - tm_type = 2; - else if (!strcmp(name, "clip_start")) - tm_type = 3; - - else - tm_type = -1; - } + if (tm_name.size()) { + if (axis_name != "") + return tm_name + "." + std::string(axis_name); + else + return tm_name; + } - switch (tm_type) { + return std::string(""); +} + +std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) +{ + std::string tm_name; + // when given rna_path, determine tm_type from it + if (rna_path) { + char *name = extract_transform_name(rna_path); + + if (!strcmp(name, "lens")) + tm_type = 0; + else if (!strcmp(name, "ortho_scale")) + tm_type = 1; + else if (!strcmp(name, "clip_end")) + tm_type = 2; + else if (!strcmp(name, "clip_start")) + tm_type = 3; + + else + tm_type = -1; + } + + switch (tm_type) { case 0: tm_name = "xfov"; break; @@ -955,56 +955,56 @@ void AnimationExporter::operator() (Object *ob) case 3: tm_name = "znear"; break; - + default: tm_name = ""; break; - } - - if (tm_name.size()) { - if (axis_name != "") - return tm_name + "." + std::string(axis_name); - else - return tm_name; - } - - return std::string(""); } - // Assign sid of the animated parameter or transform - // for rotation, axis name is always appended and the value of append_axis is ignored - std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) - { - std::string tm_name; - bool is_rotation =false; - // when given rna_path, determine tm_type from it - if (rna_path) { - char *name = extract_transform_name(rna_path); + if (tm_name.size()) { + if (axis_name != "") + return tm_name + "." + std::string(axis_name); + else + return tm_name; + } - if (!strcmp(name, "rotation_euler")) - tm_type = 0; - else if (!strcmp(name, "rotation_quaternion")) - tm_type = 1; - else if (!strcmp(name, "scale")) - tm_type = 2; - else if (!strcmp(name, "location")) - tm_type = 3; - else if (!strcmp(name, "specular_hardness")) - tm_type = 4; - else if (!strcmp(name, "specular_color")) - tm_type = 5; - else if (!strcmp(name, "diffuse_color")) - tm_type = 6; - else if (!strcmp(name, "alpha")) - tm_type = 7; - else if (!strcmp(name, "ior")) - tm_type = 8; - - else - tm_type = -1; - } + return std::string(""); +} - switch (tm_type) { +// Assign sid of the animated parameter or transform +// for rotation, axis name is always appended and the value of append_axis is ignored +std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) +{ + std::string tm_name; + bool is_rotation =false; + // when given rna_path, determine tm_type from it + if (rna_path) { + char *name = extract_transform_name(rna_path); + + if (!strcmp(name, "rotation_euler")) + tm_type = 0; + else if (!strcmp(name, "rotation_quaternion")) + tm_type = 1; + else if (!strcmp(name, "scale")) + tm_type = 2; + else if (!strcmp(name, "location")) + tm_type = 3; + else if (!strcmp(name, "specular_hardness")) + tm_type = 4; + else if (!strcmp(name, "specular_color")) + tm_type = 5; + else if (!strcmp(name, "diffuse_color")) + tm_type = 6; + else if (!strcmp(name, "alpha")) + tm_type = 7; + else if (!strcmp(name, "ior")) + tm_type = 8; + + else + tm_type = -1; + } + + switch (tm_type) { case 0: case 1: tm_name = "rotation"; @@ -1031,173 +1031,173 @@ void AnimationExporter::operator() (Object *ob) case 8: tm_name = "index_of_refraction"; break; - + default: tm_name = ""; break; + } + + if (tm_name.size()) { + if (is_rotation) + return tm_name + std::string(axis_name) + ".ANGLE"; + else + if (axis_name != "") + return tm_name + "." + std::string(axis_name); + else + return tm_name; + } + + return std::string(""); +} + +char* AnimationExporter::extract_transform_name(char *rna_path) +{ + char *dot = strrchr(rna_path, '.'); + return dot ? (dot + 1) : rna_path; +} + +//find keyframes of all the objects animations +void AnimationExporter::find_frames(Object *ob, std::vector &fra) +{ + FCurve *fcu= (FCurve*)ob->adt->action->curves.first; + + for (; fcu; fcu = fcu->next) { + + for (unsigned int i = 0; i < fcu->totvert; i++) { + float f = fcu->bezt[i].vec[1][0]; + if (std::find(fra.begin(), fra.end(), f) == fra.end()) + fra.push_back(f); } - - if (tm_name.size()) { - if (is_rotation) - return tm_name + std::string(axis_name) + ".ANGLE"; + } + + // keep the keys in ascending order + std::sort(fra.begin(), fra.end()); +} + + + +// enable fcurves driving a specific bone, disable all the rest +// if bone_name = NULL enable all fcurves +void AnimationExporter::enable_fcurves(bAction *act, char *bone_name) +{ + FCurve *fcu; + char prefix[200]; + + if (bone_name) + BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone_name); + + for (fcu = (FCurve*)act->curves.first; fcu; fcu = fcu->next) { + if (bone_name) { + if (!strncmp(fcu->rna_path, prefix, strlen(prefix))) + fcu->flag &= ~FCURVE_DISABLED; else - if (axis_name != "") - return tm_name + "." + std::string(axis_name); - else - return tm_name; + fcu->flag |= FCURVE_DISABLED; + } + else { + fcu->flag &= ~FCURVE_DISABLED; + } + } +} + +bool AnimationExporter::hasAnimations(Scene *sce) +{ + Base *base= (Base*) sce->base.first; + + while(base) { + Object *ob = base->object; + + FCurve *fcu = 0; + //Check for object transform animations + if(ob->adt && ob->adt->action) + fcu = (FCurve*)ob->adt->action->curves.first; + //Check for Lamp parameter animations + else if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) + fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first); + //Check for Camera parameter animations + else if( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) + fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); + + //Check Material Effect parameter animations. + for(int a = 0; a < ob->totcol; a++) + { + Material *ma = give_current_material(ob, a+1); + if (!ma) continue; + if(ma->adt && ma->adt->action) + { + fcu = (FCurve*)ma->adt->action->curves.first; + } } - return std::string(""); + if ( fcu) + return true; + base= base->next; } + return false; +} - char* AnimationExporter::extract_transform_name(char *rna_path) - { - char *dot = strrchr(rna_path, '.'); - return dot ? (dot + 1) : rna_path; - } +//------------------------------- Not used in the new system.-------------------------------------------------------- +void AnimationExporter::find_rotation_frames(Object *ob, std::vector &fra, const char *prefix, int rotmode) +{ + if (rotmode > 0) + find_frames(ob, fra, prefix, "rotation_euler"); + else if (rotmode == ROT_MODE_QUAT) + find_frames(ob, fra, prefix, "rotation_quaternion"); + /*else if (rotmode == ROT_MODE_AXISANGLE) + ;*/ +} - //find keyframes of all the objects animations - void AnimationExporter::find_frames(Object *ob, std::vector &fra) - { - FCurve *fcu= (FCurve*)ob->adt->action->curves.first; +void AnimationExporter::find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name) +{ + FCurve *fcu= (FCurve*)ob->adt->action->curves.first; - for (; fcu; fcu = fcu->next) { - + for (; fcu; fcu = fcu->next) { + if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix))) + continue; + + char *name = extract_transform_name(fcu->rna_path); + if (!strcmp(name, tm_name)) { for (unsigned int i = 0; i < fcu->totvert; i++) { - float f = fcu->bezt[i].vec[1][0]; // + float f = fcu->bezt[i].vec[1][0]; if (std::find(fra.begin(), fra.end(), f) == fra.end()) fra.push_back(f); } } - - // keep the keys in ascending order - std::sort(fra.begin(), fra.end()); } - + // keep the keys in ascending order + std::sort(fra.begin(), fra.end()); +} - // enable fcurves driving a specific bone, disable all the rest - // if bone_name = NULL enable all fcurves - void AnimationExporter::enable_fcurves(bAction *act, char *bone_name) - { - FCurve *fcu; - char prefix[200]; +void AnimationExporter::write_bone_animation(Object *ob_arm, Bone *bone) +{ + if (!ob_arm->adt) + return; - if (bone_name) - BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone_name); + //write bone animations for 3 transform types + //i=0 --> rotations + //i=1 --> scale + //i=2 --> location + for (int i = 0; i < 3; i++) + sample_and_write_bone_animation(ob_arm, bone, i); - for (fcu = (FCurve*)act->curves.first; fcu; fcu = fcu->next) { - if (bone_name) { - if (!strncmp(fcu->rna_path, prefix, strlen(prefix))) - fcu->flag &= ~FCURVE_DISABLED; - else - fcu->flag |= FCURVE_DISABLED; - } - else { - fcu->flag &= ~FCURVE_DISABLED; - } - } - } - - bool AnimationExporter::hasAnimations(Scene *sce) - { - Base *base= (Base*) sce->base.first; - - while(base) { - Object *ob = base->object; - - FCurve *fcu = 0; - //Check for object transform animations - if(ob->adt && ob->adt->action) - fcu = (FCurve*)ob->adt->action->curves.first; - //Check for Lamp parameter animations - else if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) - fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first); - //Check for Camera parameter animations - else if( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) - fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); - - //Check Material Effect parameter animations. - for(int a = 0; a < ob->totcol; a++) - { - Material *ma = give_current_material(ob, a+1); - if (!ma) continue; - if(ma->adt && ma->adt->action) - { - fcu = (FCurve*)ma->adt->action->curves.first; - } - } + for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) + write_bone_animation(ob_arm, child); +} - if ( fcu) - return true; - base= base->next; - } - return false; - } +void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type) +{ + bArmature *arm = (bArmature*)ob_arm->data; + int flag = arm->flag; + std::vector fra; + char prefix[256]; - //------------------------------- Not used in the new system.-------------------------------------------------------- - void AnimationExporter::find_rotation_frames(Object *ob, std::vector &fra, const char *prefix, int rotmode) - { - if (rotmode > 0) - find_frames(ob, fra, prefix, "rotation_euler"); - else if (rotmode == ROT_MODE_QUAT) - find_frames(ob, fra, prefix, "rotation_quaternion"); - /*else if (rotmode == ROT_MODE_AXISANGLE) - ;*/ - } + BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone->name); - void AnimationExporter::find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name) - { - FCurve *fcu= (FCurve*)ob->adt->action->curves.first; - - for (; fcu; fcu = fcu->next) { - if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix))) - continue; - - char *name = extract_transform_name(fcu->rna_path); - if (!strcmp(name, tm_name)) { - for (unsigned int i = 0; i < fcu->totvert; i++) { - float f = fcu->bezt[i].vec[1][0]; // - if (std::find(fra.begin(), fra.end(), f) == fra.end()) - fra.push_back(f); - } - } - } - - // keep the keys in ascending order - std::sort(fra.begin(), fra.end()); - } - - void AnimationExporter::write_bone_animation(Object *ob_arm, Bone *bone) - { - if (!ob_arm->adt) - return; - - //write bone animations for 3 transform types - //i=0 --> rotations - //i=1 --> scale - //i=2 --> location - for (int i = 0; i < 3; i++) - sample_and_write_bone_animation(ob_arm, bone, i); - - for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) - write_bone_animation(ob_arm, child); - } - - void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type) - { - bArmature *arm = (bArmature*)ob_arm->data; - int flag = arm->flag; - std::vector fra; - char prefix[256]; - - BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone->name); - - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); - if (!pchan) - return; - //Fill frame array with key frame values framed at @param:transform_type - switch (transform_type) { + bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); + if (!pchan) + return; + //Fill frame array with key frame values framed at @param:transform_type + switch (transform_type) { case 0: find_rotation_frames(ob_arm, fra, prefix, pchan->rotmode); break; @@ -1209,77 +1209,77 @@ void AnimationExporter::operator() (Object *ob) break; default: return; - } - - // exit rest position - if (flag & ARM_RESTPOS) { - arm->flag &= ~ARM_RESTPOS; - where_is_pose(scene, ob_arm); - } - //v array will hold all values which will be exported. - if (fra.size()) { - float *values = (float*)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames"); - sample_animation(values, fra, transform_type, bone, ob_arm, pchan); - - if (transform_type == 0) { - // write x, y, z curves separately if it is rotation - float *axisValues = (float*)MEM_callocN(sizeof(float) * fra.size(), "temp. anim frames"); - - for (int i = 0; i < 3; i++) { - for (unsigned int j = 0; j < fra.size(); j++) - axisValues[j] = values[j * 3 + i]; - - dae_bone_animation(fra, axisValues, transform_type, i, id_name(ob_arm), bone->name); - } - MEM_freeN(axisValues); - } - else { - // write xyz at once if it is location or scale - dae_bone_animation(fra, values, transform_type, -1, id_name(ob_arm), bone->name); - } - - MEM_freeN(values); - } - - // restore restpos - if (flag & ARM_RESTPOS) - arm->flag = flag; - where_is_pose(scene, ob_arm); } - void AnimationExporter::sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan) - { - bPoseChannel *parchan = NULL; - bPose *pose = ob_arm->pose; + // exit rest position + if (flag & ARM_RESTPOS) { + arm->flag &= ~ARM_RESTPOS; + where_is_pose(scene, ob_arm); + } + //v array will hold all values which will be exported. + if (fra.size()) { + float *values = (float*)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames"); + sample_animation(values, fra, transform_type, bone, ob_arm, pchan); - pchan = get_pose_channel(pose, bone->name); + if (transform_type == 0) { + // write x, y, z curves separately if it is rotation + float *axisValues = (float*)MEM_callocN(sizeof(float) * fra.size(), "temp. anim frames"); - if (!pchan) - return; + for (int i = 0; i < 3; i++) { + for (unsigned int j = 0; j < fra.size(); j++) + axisValues[j] = values[j * 3 + i]; - parchan = pchan->parent; - - enable_fcurves(ob_arm->adt->action, bone->name); - - std::vector::iterator it; - for (it = frames.begin(); it != frames.end(); it++) { - float mat[4][4], ipar[4][4]; - - float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); - - - BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); - where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); - - // compute bone local mat - if (bone->parent) { - invert_m4_m4(ipar, parchan->pose_mat); - mul_m4_m4m4(mat, pchan->pose_mat, ipar); + dae_bone_animation(fra, axisValues, transform_type, i, id_name(ob_arm), bone->name); } - else - copy_m4_m4(mat, pchan->pose_mat); + MEM_freeN(axisValues); + } + else { + // write xyz at once if it is location or scale + dae_bone_animation(fra, values, transform_type, -1, id_name(ob_arm), bone->name); + } - switch (type) { + MEM_freeN(values); + } + + // restore restpos + if (flag & ARM_RESTPOS) + arm->flag = flag; + where_is_pose(scene, ob_arm); +} + +void AnimationExporter::sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan) +{ + bPoseChannel *parchan = NULL; + bPose *pose = ob_arm->pose; + + pchan = get_pose_channel(pose, bone->name); + + if (!pchan) + return; + + parchan = pchan->parent; + + enable_fcurves(ob_arm->adt->action, bone->name); + + std::vector::iterator it; + for (it = frames.begin(); it != frames.end(); it++) { + float mat[4][4], ipar[4][4]; + + float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); + + + BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); + where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); + + // compute bone local mat + if (bone->parent) { + invert_m4_m4(ipar, parchan->pose_mat); + mul_m4_m4m4(mat, pchan->pose_mat, ipar); + } + else + copy_m4_m4(mat, pchan->pose_mat); + + switch (type) { case 0: mat4_to_eul(v, mat); break; @@ -1289,12 +1289,10 @@ void AnimationExporter::operator() (Object *ob) case 2: copy_v3_v3(v, mat[3]); break; - } - - v += 3; } - enable_fcurves(ob_arm->adt->action, NULL); + v += 3; } - + enable_fcurves(ob_arm->adt->action, NULL); +} diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 267ad4be887..d277dad8e8c 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -160,4 +160,4 @@ protected: char* extract_transform_name(char *rna_path); std::string getObjectBoneName ( Object *ob,const FCurve * fcu); -}; \ No newline at end of file +}; diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 4a3cd5eeb06..db32664f736 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -89,17 +89,17 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) { COLLADAFW::FloatOrDoubleArray& input = curve->getInputValues(); COLLADAFW::FloatOrDoubleArray& output = curve->getOutputValues(); - + if( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER || curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP ) { - COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues(); - COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues(); + COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues(); + COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues(); } float fps = (float)FPS; size_t dim = curve->getOutDimension(); unsigned int i; - + std::vector& fcurves = curve_map[curve->getUniqueId()]; switch (dim) { @@ -110,18 +110,18 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) { for (i = 0; i < dim; i++ ) { FCurve *fcu = (FCurve*)MEM_callocN(sizeof(FCurve), "FCurve"); - + fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED); // fcu->rna_path = BLI_strdupn(path, strlen(path)); fcu->array_index = 0; fcu->totvert = curve->getKeyCount(); - + // create beztriple for each key for (unsigned int j = 0; j < curve->getKeyCount(); j++) { BezTriple bez; memset(&bez, 0, sizeof(BezTriple)); - + // input, output bez.vec[1][0] = bc_get_float_value(input, j) * fps; bez.vec[1][1] = bc_get_float_value(output, j * dim + i); @@ -131,20 +131,20 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP) { COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues(); - COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues(); + COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues(); // intangent - bez.vec[0][0] = bc_get_float_value(intan, (j * 2 * dim ) + (2 * i)) * fps; - bez.vec[0][1] = bc_get_float_value(intan, (j * 2 * dim )+ (2 * i) + 1); + bez.vec[0][0] = bc_get_float_value(intan, (j * 2 * dim ) + (2 * i)) * fps; + bez.vec[0][1] = bc_get_float_value(intan, (j * 2 * dim )+ (2 * i) + 1); - // outtangent - bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim ) + (2 * i)) * fps; - bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim )+ (2 * i) + 1); - if(curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER) + // outtangent + bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim ) + (2 * i)) * fps; + bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim )+ (2 * i) + 1); + if(curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER) bez.ipo = BEZT_IPO_BEZ; - else - bez.ipo = BEZT_IPO_CONST; - //bez.h1 = bez.h2 = HD_AUTO; + else + bez.ipo = BEZT_IPO_CONST; + //bez.h1 = bez.h2 = HD_AUTO; } else { @@ -153,7 +153,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) } // bez.ipo = U.ipo_new; /* use default interpolation mode here... */ bez.f1 = bez.f2 = bez.f3 = SELECT; - + insert_bezt_fcurve(fcu, &bez, 0); } @@ -306,9 +306,9 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation* anim) bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList* animlist) { const COLLADAFW::UniqueId& animlist_id = animlist->getUniqueId(); - + animlist_map[animlist_id] = animlist; - + #if 0 // should not happen @@ -317,10 +317,10 @@ bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList* ani } // for bones rna_path is like: pose.bones["bone-name"].rotation - + #endif - + return true; } @@ -433,7 +433,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act) //sets the rna_path and array index to curve void AnimationImporter::modify_fcurve(std::vector* curves , char* rna_path , int array_index ) -{ +{ std::vector::iterator it; int i; for (it = curves->begin(), i = 0; it != curves->end(); it++, i++) { @@ -450,18 +450,18 @@ void AnimationImporter::modify_fcurve(std::vector* curves , char* rna_p void AnimationImporter::find_frames( std::vector* frames , std::vector* curves) { std::vector::iterator iter; - for (iter = curves->begin(); iter != curves->end(); iter++) { - FCurve *fcu = *iter; - - for (unsigned int k = 0; k < fcu->totvert; k++) { - //get frame value from bezTriple - float fra = fcu->bezt[k].vec[1][0]; - //if frame already not added add frame to frames - if (std::find(frames->begin(), frames->end(), fra) == frames->end()) - frames->push_back(fra); - - } + for (iter = curves->begin(); iter != curves->end(); iter++) { + FCurve *fcu = *iter; + + for (unsigned int k = 0; k < fcu->totvert; k++) { + //get frame value from bezTriple + float fra = fcu->bezt[k].vec[1][0]; + //if frame already not added add frame to frames + if (std::find(frames->begin(), frames->end(), fra) == frames->end()) + frames->push_back(fra); + } + } } //creates the rna_paths and array indices of fcurves from animations using transformation and bound animation class of each animation. @@ -472,18 +472,18 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType(); bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX; bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE; - + //to check if the no of curves are valid bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE ||tm_type == COLLADAFW::Transformation::SCALE) && binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ); - - + + if (!((!xyz && curves->size() == 1) || (xyz && curves->size() == 3) || is_matrix)) { fprintf(stderr, "expected %d curves, got %d\n", xyz ? 3 : 1, (int)curves->size()); return; } - + char rna_path[100]; - + switch (tm_type) { case COLLADAFW::Transformation::TRANSLATE: case COLLADAFW::Transformation::SCALE: @@ -495,80 +495,80 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * BLI_strncpy(rna_path, loc ? "location" : "scale", sizeof(rna_path)); switch (binding->animationClass) { - case COLLADAFW::AnimationList::POSITION_X: - modify_fcurve(curves, rna_path, 0 ); - break; - case COLLADAFW::AnimationList::POSITION_Y: - modify_fcurve(curves, rna_path, 1 ); - break; - case COLLADAFW::AnimationList::POSITION_Z: - modify_fcurve(curves, rna_path, 2 ); - break; - case COLLADAFW::AnimationList::POSITION_XYZ: - modify_fcurve(curves, rna_path, -1 ); - break; - default: - fprintf(stderr, "AnimationClass %d is not supported for %s.\n", - binding->animationClass, loc ? "TRANSLATE" : "SCALE"); - } - break; + case COLLADAFW::AnimationList::POSITION_X: + modify_fcurve(curves, rna_path, 0 ); + break; + case COLLADAFW::AnimationList::POSITION_Y: + modify_fcurve(curves, rna_path, 1 ); + break; + case COLLADAFW::AnimationList::POSITION_Z: + modify_fcurve(curves, rna_path, 2 ); + break; + case COLLADAFW::AnimationList::POSITION_XYZ: + modify_fcurve(curves, rna_path, -1 ); + break; + default: + fprintf(stderr, "AnimationClass %d is not supported for %s.\n", + binding->animationClass, loc ? "TRANSLATE" : "SCALE"); + } + break; } - - + + case COLLADAFW::Transformation::ROTATE: { if (is_joint) BLI_snprintf(rna_path, sizeof(rna_path), "%s.rotation_euler", joint_path); else BLI_strncpy(rna_path, "rotation_euler", sizeof(rna_path)); - std::vector::iterator iter; + std::vector::iterator iter; for (iter = curves->begin(); iter != curves->end(); iter++) { FCurve* fcu = *iter; - + //if transform is rotation the fcurves values must be turned in to radian. if (is_rotation) fcurve_deg_to_rad(fcu); } COLLADAFW::Rotate* rot = (COLLADAFW::Rotate*)transform; COLLADABU::Math::Vector3& axis = rot->getRotationAxis(); - + switch (binding->animationClass) { - case COLLADAFW::AnimationList::ANGLE: - if (COLLADABU::Math::Vector3::UNIT_X == axis) { - modify_fcurve(curves, rna_path, 0 ); - } - else if (COLLADABU::Math::Vector3::UNIT_Y == axis) { - modify_fcurve(curves, rna_path, 1 ); - } - else if (COLLADABU::Math::Vector3::UNIT_Z == axis) { - modify_fcurve(curves, rna_path, 2 ); - } - break; - case COLLADAFW::AnimationList::AXISANGLE: - // TODO convert axis-angle to quat? or XYZ? - default: - fprintf(stderr, "AnimationClass %d is not supported for ROTATE transformation.\n", - binding->animationClass); - } - break; + case COLLADAFW::AnimationList::ANGLE: + if (COLLADABU::Math::Vector3::UNIT_X == axis) { + modify_fcurve(curves, rna_path, 0 ); } - + else if (COLLADABU::Math::Vector3::UNIT_Y == axis) { + modify_fcurve(curves, rna_path, 1 ); + } + else if (COLLADABU::Math::Vector3::UNIT_Z == axis) { + modify_fcurve(curves, rna_path, 2 ); + } + break; + case COLLADAFW::AnimationList::AXISANGLE: + // TODO convert axis-angle to quat? or XYZ? + default: + fprintf(stderr, "AnimationClass %d is not supported for ROTATE transformation.\n", + binding->animationClass); + } + break; + } + case COLLADAFW::Transformation::MATRIX: /*{ - COLLADAFW::Matrix* mat = (COLLADAFW::Matrix*)transform; - COLLADABU::Math::Matrix4 mat4 = mat->getMatrix(); - switch (binding->animationClass) { - case COLLADAFW::AnimationList::TRANSFORM: - - } + COLLADAFW::Matrix* mat = (COLLADAFW::Matrix*)transform; + COLLADABU::Math::Matrix4 mat4 = mat->getMatrix(); + switch (binding->animationClass) { + case COLLADAFW::AnimationList::TRANSFORM: + + } }*/ break; case COLLADAFW::Transformation::SKEW: case COLLADAFW::Transformation::LOOKAT: fprintf(stderr, "Animation of SKEW and LOOKAT transformations is not supported yet.\n"); break; - } - + } + } //creates the rna_paths and array indices of fcurves from animations using color and bound animation class of each animation. @@ -576,15 +576,15 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list { char rna_path[100]; BLI_strncpy(rna_path,anim_type, sizeof(rna_path)); - + const COLLADAFW::AnimationList *animlist = animlist_map[listid]; const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings(); - //all the curves belonging to the current binding - std::vector animcurves; + //all the curves belonging to the current binding + std::vector animcurves; for (unsigned int j = 0; j < bindings.getCount(); j++) { - animcurves = curve_map[bindings[j].animation]; - - switch (bindings[j].animationClass) { + animcurves = curve_map[bindings[j].animation]; + + switch (bindings[j].animationClass) { case COLLADAFW::AnimationList::COLOR_R: modify_fcurve(&animcurves, rna_path, 0 ); break; @@ -598,13 +598,13 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list case COLLADAFW::AnimationList::COLOR_RGBA: // to do-> set intensity modify_fcurve(&animcurves, rna_path, -1 ); break; - + default: fprintf(stderr, "AnimationClass %d is not supported for %s.\n", - bindings[j].animationClass, "COLOR" ); + bindings[j].animationClass, "COLOR" ); } - std::vector::iterator iter; + std::vector::iterator iter; //Add the curves of the current animation to the object for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { FCurve * fcu = *iter; @@ -612,7 +612,7 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list } } - + } void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, char * anim_type) @@ -625,7 +625,7 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list const COLLADAFW::AnimationList *animlist = animlist_map[listid]; const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings(); //all the curves belonging to the current binding - std::vector animcurves; + std::vector animcurves; for (unsigned int j = 0; j < bindings.getCount(); j++) { animcurves = curve_map[bindings[j].animation]; @@ -671,28 +671,28 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector& copy_m4_m4(rest, bone->arm_mat); invert_m4_m4(irest, rest); } - // new curves to assign matrix transform animation + // new curves to assign matrix transform animation FCurve *newcu[10]; // if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale unsigned int totcu = 10 ; - const char *tm_str = NULL; + const char *tm_str = NULL; char rna_path[200]; for (int i = 0; i < totcu; i++) { int axis = i; - if (i < 4) { - tm_str = "rotation_quaternion"; - axis = i; - } - else if (i < 7) { - tm_str = "location"; - axis = i - 4; - } - else { - tm_str = "scale"; - axis = i - 7; - } - + if (i < 4) { + tm_str = "rotation_quaternion"; + axis = i; + } + else if (i < 7) { + tm_str = "location"; + axis = i - 4; + } + else { + tm_str = "scale"; + axis = i - 7; + } + if (is_joint) BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, tm_str); @@ -702,11 +702,11 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector& newcu[i]->totvert = frames.size(); } - if (frames.size() == 0) + if (frames.size() == 0) return; -std::sort(frames.begin(), frames.end()); - + std::sort(frames.begin(), frames.end()); + std::vector::iterator it; // sample values at each frame @@ -717,7 +717,7 @@ std::sort(frames.begin(), frames.end()); float matfra[4][4]; unit_m4(matfra); - + // calc object-space mat evaluate_transform_at_frame(matfra, node, fra); @@ -743,23 +743,23 @@ std::sort(frames.begin(), frames.end()); } float rot[4], loc[3], scale[3]; - - mat4_to_quat(rot, mat); - /*for ( int i = 0 ; i < 4 ; i ++ ) - { - rot[i] = rot[i] * (180 / M_PI); - }*/ - copy_v3_v3(loc, mat[3]); - mat4_to_size(scale, mat); - + + mat4_to_quat(rot, mat); + /*for ( int i = 0 ; i < 4 ; i ++ ) + { + rot[i] = rot[i] * (180 / M_PI); + }*/ + copy_v3_v3(loc, mat[3]); + mat4_to_size(scale, mat); + // add keys for (int i = 0; i < totcu; i++) { - if (i < 4) - add_bezt(newcu[i], fra, rot[i]); - else if (i < 7) - add_bezt(newcu[i], fra, loc[i - 4]); - else - add_bezt(newcu[i], fra, scale[i - 7]); + if (i < 4) + add_bezt(newcu[i], fra, rot[i]); + else if (i < 7) + add_bezt(newcu[i], fra, loc[i - 4]); + else + add_bezt(newcu[i], fra, scale[i - 7]); } } verify_adt_action((ID*)&ob->id, 1); @@ -774,13 +774,13 @@ std::sort(frames.begin(), frames.end()); BLI_addtail(curves, newcu[i]); } - if (is_joint) { - bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); - chan->rotmode = ROT_MODE_QUAT; - } - else { - ob->rotmode = ROT_MODE_QUAT; - } + if (is_joint) { + bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); + chan->rotmode = ROT_MODE_QUAT; + } + else { + ob->rotmode = ROT_MODE_QUAT; + } return; @@ -804,24 +804,24 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , bAction * act; bActionGroup *grp = NULL; - + if ( (animType->transform) != 0 ) { - const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; - char joint_path[200]; + const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; + char joint_path[200]; if ( is_joint ) - armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path)); - - + armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path)); + + if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID*)&ob->id, 1); else act = ob->adt->action; - - //Get the list of animation curves of the object - ListBase *AnimCurves = &(act->curves); + + //Get the list of animation curves of the object + ListBase *AnimCurves = &(act->curves); const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations(); - + //for each transformation in node for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) { COLLADAFW::Transformation *transform = nodeTransforms[i]; @@ -829,10 +829,10 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE; bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX; - + const COLLADAFW::UniqueId& listid = transform->getAnimationList(); - - //check if transformation has animations + + //check if transformation has animations if (animlist_map.find(listid) == animlist_map.end()) continue ; else { @@ -840,25 +840,25 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , const COLLADAFW::AnimationList *animlist = animlist_map[listid]; const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings(); //all the curves belonging to the current binding - std::vector animcurves; + std::vector animcurves; for (unsigned int j = 0; j < bindings.getCount(); j++) { - animcurves = curve_map[bindings[j].animation]; - if ( is_matrix ) - apply_matrix_curves(ob, animcurves, root , node, transform ); - else { + animcurves = curve_map[bindings[j].animation]; + if ( is_matrix ) + apply_matrix_curves(ob, animcurves, root , node, transform ); + else { //calculate rnapaths and array index of fcurves according to transformation and animation class - Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path ); - - std::vector::iterator iter; - //Add the curves of the current animation to the object - for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { - FCurve * fcu = *iter; - if ((ob->type == OB_ARMATURE)) - add_bone_fcurve( ob, node , fcu ); - else - BLI_addtail(AnimCurves, fcu); - } + Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path ); + + std::vector::iterator iter; + //Add the curves of the current animation to the object + for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { + FCurve * fcu = *iter; + if ((ob->type == OB_ARMATURE)) + add_bone_fcurve( ob, node , fcu ); + else + BLI_addtail(AnimCurves, fcu); } + } } } if (is_rotation) { @@ -880,7 +880,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , Lamp * lamp = (Lamp*) ob->data; if (!lamp->adt || !lamp->adt->action) act = verify_adt_action((ID*)&lamp->id, 1); - else act = lamp->adt->action; + else act = lamp->adt->action; ListBase *AnimCurves = &(act->curves); const COLLADAFW::InstanceLightPointerArray& nodeLights = node->getInstanceLights(); @@ -892,23 +892,23 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , { const COLLADAFW::Color *col = &(light->getColor()); const COLLADAFW::UniqueId& listid = col->getAnimationList(); - + Assign_color_animations(listid, AnimCurves, "color"); } if ((animType->light & LIGHT_FOA) != 0 ) { const COLLADAFW::AnimatableFloat *foa = &(light->getFallOffAngle()); const COLLADAFW::UniqueId& listid = foa->getAnimationList(); - + Assign_float_animations( listid ,AnimCurves, "spot_size"); } if ( (animType->light & LIGHT_FOE) != 0 ) { const COLLADAFW::AnimatableFloat *foe = &(light->getFallOffExponent()); const COLLADAFW::UniqueId& listid = foe->getAnimationList(); - + Assign_float_animations( listid ,AnimCurves, "spot_blend"); - + } } } @@ -918,7 +918,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , Camera * camera = (Camera*) ob->data; if (!camera->adt || !camera->adt->action) act = verify_adt_action((ID*)&camera->id, 1); - else act = camera->adt->action; + else act = camera->adt->action; ListBase *AnimCurves = &(act->curves); const COLLADAFW::InstanceCameraPointerArray& nodeCameras= node->getInstanceCameras(); @@ -957,12 +957,12 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , } } if ( animType->material != 0){ - Material *ma = give_current_material(ob, 1); - if (!ma->adt || !ma->adt->action) act = verify_adt_action((ID*)&ma->id, 1); - else act = ma->adt->action; + Material *ma = give_current_material(ob, 1); + if (!ma->adt || !ma->adt->action) act = verify_adt_action((ID*)&ma->id, 1); + else act = ma->adt->action; ListBase *AnimCurves = &(act->curves); - + const COLLADAFW::InstanceGeometryPointerArray& nodeGeoms = node->getInstanceGeometries(); for (unsigned int i = 0; i < nodeGeoms.getCount(); i++) { const COLLADAFW::MaterialBindingArray& matBinds = nodeGeoms[i]->getMaterialBindings(); @@ -988,7 +988,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , const COLLADAFW::UniqueId& listid = cot->getColor().getAnimationList(); Assign_color_animations( listid, AnimCurves , "specular_color" ); } - + if((animType->material & MATERIAL_DIFF_COLOR) != 0){ const COLLADAFW::ColorOrTexture *cot = &(efc->getDiffuse()); const COLLADAFW::UniqueId& listid = cot->getColor().getAnimationList(); @@ -1005,15 +1005,15 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD std::map FW_object_map) { AnimMix *types = new AnimMix(); - + const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations(); - + //for each transformation in node for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) { COLLADAFW::Transformation *transform = nodeTransforms[i]; const COLLADAFW::UniqueId& listid = transform->getAnimationList(); - - //check if transformation has animations + + //check if transformation has animations if (animlist_map.find(listid) == animlist_map.end()) continue ; else { @@ -1028,9 +1028,9 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD types->light = setAnimType(&(light->getColor()),(types->light), LIGHT_COLOR); types->light = setAnimType(&(light->getFallOffAngle()),(types->light), LIGHT_FOA); types->light = setAnimType(&(light->getFallOffExponent()),(types->light), LIGHT_FOE); - + if ( types->light != 0) break; - + } const COLLADAFW::InstanceCameraPointerArray& nodeCameras = node->getInstanceCameras(); @@ -1039,9 +1039,9 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD if ( camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE ) { - types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XFOV); + types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XFOV); } - else + else { types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XMAG); } @@ -1063,7 +1063,7 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD types->material = setAnimType(&(efc->getShininess()),(types->material), MATERIAL_SHININESS); types->material = setAnimType(&(efc->getSpecular().getColor()),(types->material), MATERIAL_SPEC_COLOR); types->material = setAnimType(&(efc->getDiffuse().getColor()),(types->material), MATERIAL_DIFF_COLOR); - // types->material = setAnimType(&(efc->get()),(types->material), MATERIAL_TRANSPARENCY); + // types->material = setAnimType(&(efc->get()),(types->material), MATERIAL_TRANSPARENCY); types->material = setAnimType(&(efc->getIndexOfRefraction()),(types->material), MATERIAL_IOR); } } @@ -1101,7 +1101,7 @@ void AnimationImporter::find_frames_old(std::vector * frames, COLLADAFW:: const COLLADAFW::AnimationList *animlist = animlist_map[listid]; const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings(); - + if (bindings.getCount()) { //for each AnimationBinding get the fcurves which animate the transform for (unsigned int j = 0; j < bindings.getCount(); j++) { @@ -1113,7 +1113,7 @@ void AnimationImporter::find_frames_old(std::vector * frames, COLLADAFW:: for (iter = curves.begin(); iter != curves.end(); iter++) { FCurve *fcu = *iter; - + //if transform is rotation the fcurves values must be turned in to radian. if (is_rotation) fcurve_deg_to_rad(fcu); @@ -1448,9 +1448,9 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float COLLADAFW::Transformation::TransformationType type = tm->getTransformationType(); if (type != COLLADAFW::Transformation::ROTATE && - type != COLLADAFW::Transformation::SCALE && - type != COLLADAFW::Transformation::TRANSLATE && - type != COLLADAFW::Transformation::MATRIX) { + type != COLLADAFW::Transformation::SCALE && + type != COLLADAFW::Transformation::TRANSLATE && + type != COLLADAFW::Transformation::MATRIX) { fprintf(stderr, "animation of transformation %d is not supported yet\n", type); return false; } @@ -1572,7 +1572,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float COLLADAFW::Matrix tm(matrix); dae_matrix_to_mat4(&tm, mat); - + std::vector::iterator it; return true; diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index 18303eb2f0b..ed9a2171c87 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -88,7 +88,7 @@ private: void add_fcurves_to_object(Object *ob, std::vector& curves, char *rna_path, int array_index, Animation *animated); int typeFlag; - + enum lightAnim { // INANIMATE = 0, @@ -144,7 +144,7 @@ public: #if 0 virtual void change_eul_to_quat(Object *ob, bAction *act); #endif - + void translate_Animations( COLLADAFW::Node * Node , std::map& root_map, std::map& object_map , @@ -161,7 +161,7 @@ public: void Assign_color_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves ,char * anim_type); void Assign_float_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, char * anim_type); - + int setAnimType ( const COLLADAFW::Animatable * prop , int type, int addition); void modify_fcurve(std::vector* curves , char* rna_path , int array_index ); @@ -206,5 +206,5 @@ public: void extra_data_importer(std::string elementName); }; - - #endif + +#endif diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 92d06bb639f..de01c000373 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -188,7 +188,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm) for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) { add_bone_node(child, ob_arm); } - node.end(); + node.end(); //} } diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 1e7879b352f..27aee133557 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -87,7 +87,7 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p if ( it != finished_joints.end()) return; float mat[4][4]; - float obmat[4][4]; + float obmat[4][4]; // object-space get_node_mat(obmat, node, NULL, NULL); @@ -296,7 +296,7 @@ void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW: et->setData("tip_z",&z); float vec[3] = {x,y,z}; copy_v3_v3(leaf.bone->tail, leaf.bone->head); - add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec); + add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec); }else leaf_bones.push_back(leaf); } @@ -310,9 +310,10 @@ void ArmatureImporter::fix_leaf_bones( ) LeafBone& leaf = *it; // pointing up - float vec[3] = {0.0f, 0.0f, 1.0f}; + float vec[3] = {0.0f, 0.0f, 0.1f}; - //mul_v3_fl(vec, leaf_bone_length); + // if parent: take parent length and direction + if(leaf.bone->parent) sub_v3_v3v3(vec, leaf.bone->parent->tail, leaf.bone->parent->head); copy_v3_v3(leaf.bone->tail, leaf.bone->head); add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec); diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h index 4f4aed210f2..a197e612a87 100644 --- a/source/blender/collada/ArmatureImporter.h +++ b/source/blender/collada/ArmatureImporter.h @@ -115,7 +115,7 @@ private: void fix_leaf_bones(); - void set_pose ( Object * ob_arm , COLLADAFW::Node * root_node ,char * parentname, float parent_mat[][4]); + void set_pose ( Object * ob_arm , COLLADAFW::Node * root_node ,char * parentname, float parent_mat[][4]); #if 0 @@ -171,7 +171,7 @@ public: // gives a world-space mat bool get_joint_bind_mat(float m[][4], COLLADAFW::Node *joint); - + void set_tags_map( TagsMap& tags_map); }; diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index 285ab283b37..6e780889d16 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -328,9 +328,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename, bool //scale = RNA_struct_find_property(&unit_settings, "scale_length"); std::string unitname = "meter"; - float linearmeasure = 1.0f; - - linearmeasure = RNA_float_get(&unit_settings, "scale_length"); + float linearmeasure = RNA_float_get(&unit_settings, "scale_length"); switch(RNA_property_enum_get(&unit_settings, system)) { case USER_UNIT_NONE: @@ -368,8 +366,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename, bool asset.setUnit(unitname, linearmeasure); asset.setUpAxisType(COLLADASW::Asset::Z_UP); - // TODO: need an Author field in userpref - if(strlen(U.author) > 0) { + if(U.author[0] != '\0') { asset.getContributor().mAuthor = U.author; } else { diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp index a60ef8b2ea5..820665ad757 100644 --- a/source/blender/collada/ExtraHandler.cpp +++ b/source/blender/collada/ExtraHandler.cpp @@ -56,7 +56,7 @@ bool ExtraHandler::textData(const char* text, size_t textLength) { char buf[1024]; - if(currentElement.length() == 0) return false; + if(currentElement.length() == 0 || currentExtraTags == 0) return false; BLI_snprintf(buf, textLength+1, "%s", text); currentExtraTags->addTag(currentElement, std::string(buf)); diff --git a/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp index 653d4a377cd..f0c6d2228b1 100644 --- a/source/blender/collada/ExtraTags.cpp +++ b/source/blender/collada/ExtraTags.cpp @@ -90,32 +90,28 @@ std::string ExtraTags::asString( std::string tag, bool *ok) void ExtraTags::setData(std::string tag, short *data) { bool ok = false; - int tmp = 0; - tmp = asInt(tag, &ok); + int tmp = asInt(tag, &ok); if(ok) *data = (short)tmp; } void ExtraTags::setData(std::string tag, int *data) { bool ok = false; - int tmp = 0; - tmp = asInt(tag, &ok); + int tmp = asInt(tag, &ok); if(ok) *data = tmp; } void ExtraTags::setData(std::string tag, float *data) { bool ok = false; - float tmp = 0.0f; - tmp = asFloat(tag, &ok); + float tmp = asFloat(tag, &ok); if(ok) *data = tmp; } void ExtraTags::setData(std::string tag, char *data) { bool ok = false; - int tmp = 0; - tmp = asInt(tag, &ok); + int tmp = asInt(tag, &ok); if(ok) *data = (char)tmp; } diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 760fb2359a4..e9086f05628 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -220,8 +220,8 @@ void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs, if (quad) uvs.getUV(indices[index + 3], mtface->uv[3]); -#ifdef COLLADA_DEBUG - /*if (quad) { +#if 1 // #ifdef COLLADA_DEBUG + if (quad) { fprintf(stderr, "face uv:\n" "((%d, %d, %d, %d))\n" "((%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f))\n", @@ -248,7 +248,7 @@ void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs, mtface->uv[0][0], mtface->uv[0][1], mtface->uv[1][0], mtface->uv[1][1], mtface->uv[2][0], mtface->uv[2][1]); - }*/ + } #endif } @@ -411,7 +411,7 @@ int MeshImporter::count_new_tris(COLLADAFW::Mesh *mesh, Mesh *me) } // TODO: import uv set names -void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //TODO:: Refactor. Possibly replace by iterators +void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //TODO:: Refactor. Possibly replace by iterators { unsigned int i; @@ -587,7 +587,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) for (k = 0; k < index_list_array.getCount(); k++) { // get mtface by face index and uv set index MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k); - set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, mface->v4 != 0); + set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, vcount == 4); } #endif diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index ce0d561c524..1d890415ebe 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -266,9 +266,9 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::mapmat4_to_dae_double(dmat,local); + converter->mat4_to_dae_double(dmat,local); TransformBase::decompose(local, loc, rot, NULL, scale); if ( node.getType() == COLLADASW::Node::JOINT) diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 8010a41ccb3..bb710a32794 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1177,29 +1177,34 @@ static size_t animfilter_nla (bAnimContext *UNUSED(ac), ListBase *anim_data, bDo /* determine what animation data from AnimData block should get displayed */ static size_t animfilter_block_data (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *id, int filter_mode) { - IdAdtTemplate *iat = (IdAdtTemplate*)id; AnimData *adt = BKE_animdata_from_id(id); size_t items = 0; - - /* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed - * in a few places in he rest of the code still - notably for the few cases where special mode-based - * different types of data expanders are required. - */ - ANIMDATA_FILTER_CASES(iat, - { /* AnimData */ - /* specifically filter animdata block */ - ANIMCHANNEL_NEW_CHANNEL(adt, ANIMTYPE_ANIMDATA, id); - }, - { /* NLA */ - items += animfilter_nla(ac, anim_data, ads, adt, filter_mode, id); - }, - { /* Drivers */ - items += animfilter_fcurves(anim_data, ads, adt->drivers.first, NULL, filter_mode, id); - }, - { /* Keyframes */ - items += animfilter_action(ac, anim_data, ads, adt->action, filter_mode, id); - }); - + + /* image object datablocks have no anim-data so check for NULL */ + if(adt) { + IdAdtTemplate *iat = (IdAdtTemplate*)id; + + /* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed + * in a few places in he rest of the code still - notably for the few cases where special mode-based + * different types of data expanders are required. + */ + ANIMDATA_FILTER_CASES(iat, + { /* AnimData */ + /* specifically filter animdata block */ + ANIMCHANNEL_NEW_CHANNEL(adt, ANIMTYPE_ANIMDATA, id); + }, + { /* NLA */ + items += animfilter_nla(ac, anim_data, ads, adt, filter_mode, id); + }, + { /* Drivers */ + items += animfilter_fcurves(anim_data, ads, adt->drivers.first, NULL, filter_mode, id); + }, + { /* Keyframes */ + items += animfilter_action(ac, anim_data, ads, adt->action, filter_mode, id); + } + ); + } + return items; } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 4e87409b7fd..53c9fc4d82c 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -530,6 +530,7 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) { bConstraint *con= NULL; short searchtype= VISUALKEY_NONE; + short has_parent = FALSE; char *identifier= NULL; /* validate data */ @@ -548,6 +549,7 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) con= ob->constraints.first; identifier= (char *)RNA_property_identifier(prop); + has_parent= (ob->parent != NULL); } else if (ptr->type == &RNA_PoseBone) { /* Pose Channel */ @@ -555,10 +557,11 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) con= pchan->constraints.first; identifier= (char *)RNA_property_identifier(prop); + has_parent= (pchan->parent != NULL); } /* check if any data to search using */ - if (ELEM(NULL, con, identifier)) + if (ELEM(NULL, con, identifier) && (has_parent == FALSE)) return 0; /* location or rotation identifiers only... */ @@ -573,7 +576,12 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) /* only search if a searchtype and initial constraint are available */ - if (searchtype && con) { + if (searchtype) { + /* parent is always matching */ + if (has_parent) + return 1; + + /* constraints */ for (; con; con= con->next) { /* only consider constraint if it is not disabled, and has influence */ if (con->flag & CONSTRAINT_DISABLE) continue; @@ -645,39 +653,34 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_ if (ptr->type == &RNA_Object) { Object *ob= (Object *)ptr->data; - /* parented objects are not supported, as the effects of the parent - * are included in the matrix, which kindof beats the point - */ - if (ob->parent == NULL) { - /* only Location or Rotation keyframes are supported now */ - if (strstr(identifier, "location")) { - return ob->obmat[3][array_index]; - } - else if (strstr(identifier, "rotation_euler")) { - float eul[3]; - - mat4_to_eulO(eul, ob->rotmode, ob->obmat); - return eul[array_index]; - } - else if (strstr(identifier, "rotation_quaternion")) { - float trimat[3][3], quat[4]; - - copy_m3_m4(trimat, ob->obmat); - mat3_to_quat_is_ok(quat, trimat); - - return quat[array_index]; - } - else if (strstr(identifier, "rotation_axis_angle")) { - float axis[3], angle; - - mat4_to_axis_angle(axis, &angle, ob->obmat); - - /* w = 0, x,y,z = 1,2,3 */ - if (array_index == 0) - return angle; - else - return axis[array_index - 1]; - } + /* only Location or Rotation keyframes are supported now */ + if (strstr(identifier, "location")) { + return ob->obmat[3][array_index]; + } + else if (strstr(identifier, "rotation_euler")) { + float eul[3]; + + mat4_to_eulO(eul, ob->rotmode, ob->obmat); + return eul[array_index]; + } + else if (strstr(identifier, "rotation_quaternion")) { + float trimat[3][3], quat[4]; + + copy_m3_m4(trimat, ob->obmat); + mat3_to_quat_is_ok(quat, trimat); + + return quat[array_index]; + } + else if (strstr(identifier, "rotation_axis_angle")) { + float axis[3], angle; + + mat4_to_axis_angle(axis, &angle, ob->obmat); + + /* w = 0, x,y,z = 1,2,3 */ + if (array_index == 0) + return angle; + else + return axis[array_index - 1]; } } else if (ptr->type == &RNA_PoseBone) { diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 76ed9891b8e..2267f04aab4 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -770,7 +770,11 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol) glColor4f(0.f, 0.f, 0.f, 0.3f); uiSetRoundBox(15); uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); - + + /* need scissor test, histogram can draw outside of boundary */ + glGetIntegerv(GL_VIEWPORT, scissor); + glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1)); + glColor4f(1.f, 1.f, 1.f, 0.08f); /* draw grid lines here */ for (i=1; i<4; i++) { @@ -778,10 +782,6 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol) fdrawline(rect.xmin+(i/4.f)*w, rect.ymin, rect.xmin+(i/4.f)*w, rect.ymax); } - /* need scissor test, histogram can draw outside of boundary */ - glGetIntegerv(GL_VIEWPORT, scissor); - glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1)); - if (hist->mode == HISTO_MODE_LUMA) histogram_draw_one(1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_luma, res); else { diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index 132db6caaeb..7673bd8f31c 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1099,7 +1099,7 @@ void load_editMesh(Scene *scene, Object *obedit) int j; for (ob=G.main->object.first; ob; ob=ob->id.next) { - if (ob->parent==ob && ELEM(ob->partype, PARVERT1,PARVERT3)) { + if (ob->parent==obedit && ELEM(ob->partype, PARVERT1,PARVERT3)) { /* duplicate code from below, make it function later...? */ if (!vertMap) { diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index b7ed6ec14ca..0afa2d01702 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -1141,6 +1141,9 @@ short extrudeflag_face_indiv(EditMesh *em, short UNUSED(flag), float *UNUSED(nor EM_select_flush(em); + /* step 5; update normals after extrude */ + recalc_editnormals(em); + return 'n'; } @@ -1206,6 +1209,9 @@ short extrudeflag_edges_indiv(EditMesh *em, short flag, float *nor) if(eed->v1->f & eed->v2->f & flag) eed->f |= flag; } + /* update normals after extrude */ + recalc_editnormals(em); + if(is_zero_v3(nor)) return 'g'; // g is grab return 'n'; // n is for normal constraint } @@ -1485,6 +1491,9 @@ static short extrudeflag_edge(Object *obedit, EditMesh *em, short UNUSED(flag), EM_select_flush(em); + /* step 8; update normals after extrude */ + recalc_editnormals(em); + if(is_zero_v3(nor)) return 'g'; // grab return 'n'; // normal constraint } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 5212bf32834..fa529374bf7 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -276,8 +276,10 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa RNA_boolean_set(op->ptr, "view_align", view_align); } - if (view_align) + if (view_align) { ED_object_rotation_from_view(C, rot); + RNA_float_set_array(op->ptr, "rotation", rot); + } else RNA_float_get_array(op->ptr, "rotation", rot); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index ee162464c70..07c006a7995 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -159,7 +159,7 @@ typedef struct { static void multiresbake_get_normal(const MResolvePixelData *data, float norm[], const int face_num, const int vert_index) { unsigned int indices[]= {data->mface[face_num].v1, data->mface[face_num].v2, - data->mface[face_num].v3, data->mface[face_num].v4}; + data->mface[face_num].v3, data->mface[face_num].v4}; const int smoothnormal= (data->mface[face_num].flag & ME_SMOOTH); if(!smoothnormal) { /* flat */ diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 61734bc51a2..79cbfb6574b 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1411,6 +1411,8 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) else ob->pd->forcefield = 0; + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, NULL); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index bb32869469a..266556773f0 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -64,6 +64,7 @@ #include "ED_curve.h" #include "ED_mesh.h" +#include "ED_lattice.h" #include "ED_screen.h" #include "WM_types.h" @@ -292,7 +293,7 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo return totvert; } -static int object_hook_index_array(Object *obedit, int *tot, int **indexar, char *name, float *cent_r) +static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int **indexar, char *name, float *cent_r) { *indexar= NULL; *tot= 0; @@ -302,7 +303,12 @@ static int object_hook_index_array(Object *obedit, int *tot, int **indexar, char case OB_MESH: { Mesh *me= obedit->data; - EditMesh *em = BKE_mesh_get_editmesh(me); + EditMesh *em; + + load_editMesh(scene, obedit); + make_editMesh(scene, obedit); + + em = BKE_mesh_get_editmesh(me); /* check selected vertices first */ if( return_editmesh_indexar(em, tot, indexar, cent_r)) { @@ -316,10 +322,17 @@ static int object_hook_index_array(Object *obedit, int *tot, int **indexar, char } case OB_CURVE: case OB_SURF: + load_editNurb(obedit); + make_editNurb(obedit); + return return_editcurve_indexar(obedit, tot, indexar, cent_r); case OB_LATTICE: { Lattice *lt= obedit->data; + + load_editLatt(obedit); + make_editLatt(obedit); + return return_editlattice_indexar(lt->editlatt->latt, tot, indexar, cent_r); } default: @@ -427,7 +440,7 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o int tot, ok, *indexar; char name[32]; - ok = object_hook_index_array(obedit, &tot, &indexar, name, cent); + ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent); if (!ok) return; // XXX error("Requires selected vertices or active Vertex Group"); @@ -760,7 +773,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) /* assign functionality */ - if(!object_hook_index_array(ob, &tot, &indexar, name, cent)) { + if(!object_hook_index_array(CTX_data_scene(C), ob, &tot, &indexar, name, cent)) { BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index e9418ca9f9f..b9208e778c7 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -91,6 +91,8 @@ #include "ED_armature.h" #include "ED_curve.h" +#include "ED_lattice.h" +#include "ED_mesh.h" #include "ED_keyframing.h" #include "ED_object.h" #include "ED_screen.h" @@ -122,7 +124,12 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) if(obedit->type==OB_MESH) { Mesh *me= obedit->data; - EditMesh *em = BKE_mesh_get_editmesh(me); + EditMesh *em; + + load_editMesh(scene, obedit); + make_editMesh(scene, obedit); + + em = BKE_mesh_get_editmesh(me); eve= em->verts.first; while(eve) { @@ -140,7 +147,12 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(me, em); } else if(ELEM(obedit->type, OB_SURF, OB_CURVE)) { - ListBase *editnurb= curve_get_editcurve(obedit); + ListBase *editnurb; + + load_editNurb(obedit); + make_editNurb(obedit); + + editnurb= curve_get_editcurve(obedit); cu= obedit->data; @@ -180,8 +192,13 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) } } else if(obedit->type==OB_LATTICE) { - Lattice *lt= obedit->data; - + Lattice *lt; + + load_editLatt(obedit); + make_editLatt(obedit); + + lt= obedit->data; + a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; bp= lt->editlatt->latt->def; while(a--) { diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index e66abffbfd1..70884d47c23 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -221,6 +221,7 @@ void SOUND_OT_open_mono(wmOperatorType *ot) static int mixdown_exec(bContext *C, wmOperator *op) { +#ifdef WITH_AUDASPACE char path[FILE_MAX]; char filename[FILE_MAX]; Scene *scene; @@ -254,7 +255,10 @@ static int mixdown_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, result); return OPERATOR_CANCELLED; } - +#else // WITH_AUDASPACE + (void)C; + (void)op; +#endif // WITH_AUDASPACE return OPERATOR_FINISHED; } @@ -278,6 +282,7 @@ static int mixdown_draw_check_prop(PropertyRNA *prop) ); } +#ifdef WITH_AUDASPACE static void mixdown_draw(bContext *C, wmOperator *op) { static EnumPropertyItem pcm_format_items[] = { @@ -429,9 +434,11 @@ static void mixdown_draw(bContext *C, wmOperator *op) /* main draw call */ uiDefAutoButsRNA(layout, &ptr, mixdown_draw_check_prop, '\0'); } +#endif // WITH_AUDASPACE void SOUND_OT_mixdown(wmOperatorType *ot) { +#ifdef WITH_AUDASPACE static EnumPropertyItem format_items[] = { {AUD_FORMAT_U8, "U8", 0, "U8", "8 bit unsigned"}, {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, @@ -469,6 +476,8 @@ void SOUND_OT_mixdown(wmOperatorType *ot) {AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"}, {0, NULL, 0, NULL, NULL}}; +#endif // WITH_AUDASPACE + /* identifiers */ ot->name= "Mixdown"; ot->description= "Mixes the scene's audio to a sound file"; @@ -477,18 +486,22 @@ void SOUND_OT_mixdown(wmOperatorType *ot) /* api callbacks */ ot->exec= mixdown_exec; ot->invoke= mixdown_invoke; - ot->ui= mixdown_draw; +#ifdef WITH_AUDASPACE + ot->ui= mixdown_draw; +#endif /* flags */ ot->flag= OPTYPE_REGISTER; /* properties */ WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH); +#ifdef WITH_AUDASPACE RNA_def_int(ot->srna, "accuracy", 1024, 1, 16777216, "Accuracy", "Sample accuracy. Important for animation data. The lower the value, the more accurate.", 1, 16777216); RNA_def_enum(ot->srna, "container", container_items, AUD_CONTAINER_FLAC, "Container", "File format"); RNA_def_enum(ot->srna, "codec", codec_items, AUD_CODEC_FLAC, "Codec", "Audio Codec"); RNA_def_enum(ot->srna, "format", format_items, AUD_FORMAT_S16, "Format", "Sample format"); RNA_def_int(ot->srna, "bitrate", 192, 32, 512, "Bitrate", "Bitrate in kbit/s", 32, 512); +#endif // WITH_AUDASPACE } /* ******************************************************* */ diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index d58b78ff6a7..68f9e4d033e 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -960,20 +960,19 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, if(ibuf) { Image *ima= sima->image; - RenderResult *rr= BKE_image_acquire_renderresult(scene, ima); simopts->planes= ibuf->depth; - /* cant save multilayer sequence, ima->rr isn't valid for a specific frame */ - if(rr && !(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER)) - simopts->imtype= R_MULTILAYER; - else if(ima->type==IMA_TYPE_R_RESULT) + if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { simopts->imtype= scene->r.imtype; - else if (ima->source == IMA_SRC_GENERATED) + simopts->planes= scene->r.planes; + } + else if (ima->source == IMA_SRC_GENERATED) { simopts->imtype= R_PNG; - else + } + else { simopts->imtype= BKE_ftype_to_imtype(ibuf->ftype); - + } simopts->subimtype= scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */ simopts->quality= ibuf->ftype & 0xff; @@ -1000,8 +999,6 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, } BLI_path_abs(simopts->filepath, G.main->name); } - /* cleanup */ - BKE_image_release_renderresult(scene, ima); } ED_space_image_release_buffer(sima, lock); @@ -1016,7 +1013,10 @@ static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op // if (RNA_property_is_set(op->ptr, "subimtype")) simopts->subimtype= RNA_enum_get(op->ptr, "subimtype"); // XXX if (RNA_property_is_set(op->ptr, "file_quality")) simopts->quality= RNA_int_get(op->ptr, "file_quality"); - if (RNA_property_is_set(op->ptr, "filepath")) RNA_string_get(op->ptr, "filepath", simopts->filepath); + if (RNA_property_is_set(op->ptr, "filepath")) { + RNA_string_get(op->ptr, "filepath", simopts->filepath); + BLI_path_abs(simopts->filepath, G.main->name); + } } static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op) @@ -1069,7 +1069,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI Scene *scene= CTX_data_scene(C); RenderResult *rr= BKE_image_acquire_renderresult(scene, ima); if(rr) { - RE_WriteRenderResult(rr, simopts->filepath, simopts->quality); + RE_WriteRenderResult(op->reports, rr, simopts->filepath, simopts->quality); ok= TRUE; } else { diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 882d89fcd33..920e93cc0fc 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3677,7 +3677,7 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; PointerRNA settings_ptr; - uiLayout *row, *subrow, *col;; + uiLayout *row, *subrow, *col; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index c32d05e9c30..0474d1f3bb1 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1385,7 +1385,7 @@ static void node_texture_set_butfunc(bNodeType *ntype) default: ntype->uifunc= NULL; } - if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc; + if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc; } /* ******* init draw callbacks for all tree types, only called in usiblender.c, once ************* */ diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 0cb05fa2115..95a315272b9 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -236,7 +236,7 @@ static int group_select_flag(Group *gr) return 0; } -static void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) +void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) { Scene *scene = (Scene *)poin; GroupObject *gob; diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index fbd5281b1d9..2b451a48748 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -218,6 +218,34 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) /* Rename --------------------------------------------------- */ +void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports) +{ + /* can't rename rna datablocks entries */ + if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) + ; + else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) + BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); + else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) + BKE_report(reports, RPT_WARNING, "Cannot edit sequence name"); + else if(tselem->id->lib) { + // XXX error_libdata(); + } + else if(te->idcode == ID_LI && te->parent) { + BKE_report(reports, RPT_WARNING, "Cannot edit the path of an indirectly linked library"); + } + else { + tselem->flag |= TSE_TEXTBUT; + ED_region_tag_redraw(ar); + } +} + +void item_rename_cb(bContext *C, Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + ARegion *ar= CTX_wm_region(C); + ReportList *reports= CTX_wm_reports(C); // XXX + do_item_rename(ar, te, tselem, reports) ; +} + static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2]) { ReportList *reports= CTX_wm_reports(C); // XXX @@ -228,23 +256,7 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T /* name and first icon */ if(mval[0]>te->xs+UI_UNIT_X && mval[0]xend) { - /* can't rename rna datablocks entries */ - if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) - ; - else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) - BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); - else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) - BKE_report(reports, RPT_WARNING, "Cannot edit sequence name"); - else if(tselem->id->lib) { - // XXX error_libdata(); - } - else if(te->idcode == ID_LI && te->parent) { - BKE_report(reports, RPT_WARNING, "Cannot edit the path of an indirectly linked library"); - } - else { - tselem->flag |= TSE_TEXTBUT; - ED_region_tag_redraw(ar); - } + do_item_rename(ar, te, tselem, reports) ; } return 1; } @@ -377,6 +389,12 @@ void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, Tre } } +void group_toggle_visibility_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Group *group= (Group *)tselem->id; + restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_VIEW); +} + static int outliner_toggle_visibility_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); @@ -417,6 +435,12 @@ void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme } } +void group_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Group *group= (Group *)tselem->id; + restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_SELECT); +} + static int outliner_toggle_selectability_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); @@ -457,6 +481,12 @@ void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme } } +void group_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Group *group= (Group *)tselem->id; + restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_RENDER); +} + static int outliner_toggle_renderability_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 9da09144125..61507d1ffe5 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -129,6 +129,7 @@ typedef struct TreeElement { /* outliner_tree.c ----------------------------------------------- */ void outliner_free_tree(ListBase *lb); +void outliner_cleanup_tree(struct SpaceOops *soops); TreeElement *outliner_find_tse(struct SpaceOops *soops, TreeStoreElem *tse); TreeElement *outliner_find_id(struct SpaceOops *soops, ListBase *lb, struct ID *id); @@ -139,6 +140,7 @@ void outliner_build_tree(struct Main *mainvar, struct Scene *scene, struct Space /* outliner_draw.c ---------------------------------------------- */ void draw_outliner(const struct bContext *C); +void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag); /* outliner_select.c -------------------------------------------- */ int tree_element_type_active(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set); @@ -158,6 +160,13 @@ void object_toggle_visibility_cb(struct bContext *C, struct Scene *scene, TreeEl void object_toggle_selectability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); void object_toggle_renderability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); + +void group_toggle_visibility_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); +void group_toggle_selectability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); +void group_toggle_renderability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); + +void item_rename_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); + /* ...................................................... */ void OUTLINER_OT_item_activate(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 3ae158bd275..b3170f9cd1e 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -287,6 +287,8 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); if(base) { + SpaceOops *soops= CTX_wm_space_outliner(C); + // check also library later if(scene->obedit==base->object) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); @@ -294,6 +296,13 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); te->directdata= NULL; tselem->id= NULL; + + /* XXX: tree management normally happens from draw_outliner(), but when + you're clicking to fast on Delete object from context menu in + outliner several mouse events can be handled in one cycle without + handling notifiers/redraw which leads to deleting the same object twice. + cleanup tree here to prevent such cases. */ + outliner_cleanup_tree(soops); } } @@ -510,6 +519,7 @@ static EnumPropertyItem prop_object_op_types[] = { {6, "TOGVIS", 0, "Toggle Visible", ""}, {7, "TOGSEL", 0, "Toggle Selectable", ""}, {8, "TOGREN", 0, "Toggle Renderable", ""}, + {9, "RENAME", 0, "Rename", ""}, {0, NULL, 0, NULL, NULL} }; @@ -567,6 +577,10 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) str= "Toggle Renderability"; WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene); } + else if(event==9) { + outliner_do_object_operation(C, scene, soops, &soops->tree, item_rename_cb); + str= "Rename Object"; + } ED_undo_push(C, str); @@ -600,6 +614,7 @@ static EnumPropertyItem prop_group_op_types[] = { {4, "TOGVIS", 0, "Toggle Visible", ""}, {5, "TOGSEL", 0, "Toggle Selectable", ""}, {6, "TOGREN", 0, "Toggle Renderable", ""}, + {7, "RENAME", 0, "Rename", ""}, {0, NULL, 0, NULL, NULL} }; @@ -608,6 +623,7 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); SpaceOops *soops= CTX_wm_space_outliner(C); int event; + const char *str= NULL; /* check for invalid states */ if (soops == NULL) @@ -617,18 +633,35 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op) if(event==1) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); - ED_undo_push(C, "Unlink group"); + str= "Unlink group"; } else if(event==2) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); - ED_undo_push(C, "Localized Data"); + str= "Localized Data"; } else if(event==3) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); - ED_undo_push(C, "Link Group Objects to Scene"); + str= "Link Group Objects to Scene"; + } + else if(event==4) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb); + str= "Toggle Visibility"; + } + else if(event==5) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb); + str= "Toggle Selectability"; + } + else if(event==6) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb); + str= "Toggle Renderability"; + } + else if(event==7) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); + str= "Rename"; } + ED_undo_push(C, str); WM_event_add_notifier(C, NC_GROUP, NULL); return OPERATOR_FINISHED; @@ -662,7 +695,8 @@ typedef enum eOutlinerIdOpTypes { OUTLINER_IDOP_SINGLE, OUTLINER_IDOP_FAKE_ADD, - OUTLINER_IDOP_FAKE_CLEAR + OUTLINER_IDOP_FAKE_CLEAR, + OUTLINER_IDOP_RENAME } eOutlinerIdOpTypes; // TODO: implement support for changing the ID-block used @@ -672,6 +706,7 @@ static EnumPropertyItem prop_id_op_types[] = { {OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""}, {OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User", "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"}, {OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""}, + {OUTLINER_IDOP_RENAME, "RENAME", 0, "Rename", ""}, {0, NULL, 0, NULL, NULL} }; @@ -765,6 +800,14 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) ED_undo_push(C, "Clear Fake User"); } break; + case OUTLINER_IDOP_RENAME: + /* rename */ + outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); + + WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + ED_undo_push(C, "Rename"); + + break; default: // invalid - unhandled diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 0b07c824f3e..8904dcc360f 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -222,6 +222,12 @@ void outliner_free_tree(ListBase *lb) } } +void outliner_cleanup_tree(SpaceOops *soops) +{ + outliner_free_tree(&soops->tree); + outliner_storage_cleanup(soops); +} + /* Find ith item from the treestore */ static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) { diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index c7d4d78422e..47f051e1ec4 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -154,6 +154,11 @@ static void text_listener(ScrArea *sa, wmNotifier *wmn) case NA_REMOVED: ED_area_tag_redraw(sa); break; + case NA_SELECTED: + if(st->text && st->text == wmn->reference) + text_scroll_to_cursor(st, sa); + + break; } break; diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 28230b7a48b..066404f23ba 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1821,12 +1821,10 @@ void text_update_character_width(SpaceText *st) /* Moves the view to the cursor location, also used to make sure the view isnt outside the file */ -void text_update_cursor_moved(bContext *C) +void text_scroll_to_cursor(SpaceText *st, ScrArea *sa) { - ScrArea *sa= CTX_wm_area(C); - SpaceText *st= CTX_wm_space_text(C); Text *text; - ARegion *ar; + ARegion *ar= NULL; int i, x, winx= 0; if(ELEM3(NULL, st, st->text, st->text->curl)) return; @@ -1834,8 +1832,10 @@ void text_update_cursor_moved(bContext *C) text= st->text; for(ar=sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_WINDOW) + if(ar->regiontype==RGN_TYPE_WINDOW) { winx= ar->winx; + break; + } winx -= TXT_SCROLL_WIDTH; @@ -1844,7 +1844,7 @@ void text_update_cursor_moved(bContext *C) i= txt_get_span(text->lines.first, text->sell); if(st->wordwrap) { int offl, offc; - wrap_offset(st, CTX_wm_region(C), text->sell, text->selc, &offl, &offc); + wrap_offset(st, ar, text->sell, text->selc, &offl, &offc); i+= offl; } @@ -1865,3 +1865,10 @@ void text_update_cursor_moved(bContext *C) if(st->left <0) st->left= 0; } +void text_update_cursor_moved(bContext *C) +{ + ScrArea *sa= CTX_wm_area(C); + SpaceText *st= CTX_wm_space_text(C); + + text_scroll_to_cursor(st, sa); +} diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index cb55f41acb5..b34c7815f35 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -55,6 +55,7 @@ int text_font_width(struct SpaceText *st, const char *str); void text_update_line_edited(struct TextLine *line); void text_update_edited(struct Text *text); void text_update_character_width(struct SpaceText *st); +void text_scroll_to_cursor(struct SpaceText *st, struct ScrArea *sa); void text_update_cursor_moved(struct bContext *C); /* TXT_OFFSET used to be 35 when the scrollbar was on the left... */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index e9ed5dac3de..19e8d42db2d 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3475,7 +3475,7 @@ void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist) copy_m3_m4(nmat, mat); normalize_m3(nmat); - mul_m3_v3(nmat, vec);; + mul_m3_v3(nmat, vec); sub_v3_v3(ofs, vec); } } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index c48459108eb..44ae6837aa2 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -625,8 +625,8 @@ void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[ } } else { - const float dx= (2.0f * mval[0] / (float)ar->winx) - 1.0f; - const float dy= (2.0f * mval[1] / (float)ar->winy) - 1.0f; + const float dx= (2.0f * mval[0] / (float)ar->winx) - 1.0f; + const float dy= (2.0f * mval[1] / (float)ar->winy) - 1.0f; line_sta[0]= (rv3d->persinv[0][0] * dx) + (rv3d->persinv[1][0] * dy) + rv3d->viewinv[3][0]; line_sta[1]= (rv3d->persinv[0][1] * dx) + (rv3d->persinv[1][1] * dy) + rv3d->viewinv[3][1]; line_sta[2]= (rv3d->persinv[0][2] * dx) + (rv3d->persinv[1][2] * dy) + rv3d->viewinv[3][2]; diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 1fbe8e01fd4..2c926f2d94b 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -499,7 +499,7 @@ void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, i void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value); /* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */ -void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2); +void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2); /* defined in metadata.c */ int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field); diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 7b172008bee..c4fe1523e90 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -922,7 +922,7 @@ static int ffmpeg_decode_video_frame(struct anim * anim) static void ffmpeg_decode_video_frame_scan( struct anim * anim, int64_t pts_to_search) { - /* there seem to exist *very* silly GOP lengths out in the wild... */ + /* there seem to exist *very* silly GOP lengths out in the wild... */ int count = 1000; av_log(anim->pFormatCtx, diff --git a/source/blender/imbuf/intern/indexer_dv.c b/source/blender/imbuf/intern/indexer_dv.c index 2def0d042b7..d1202136d56 100644 --- a/source/blender/imbuf/intern/indexer_dv.c +++ b/source/blender/imbuf/intern/indexer_dv.c @@ -30,8 +30,8 @@ #include typedef struct indexer_dv_bitstream { - unsigned char* buffer; - int bit_pos; + unsigned char* buffer; + int bit_pos; } indexer_dv_bitstream; static indexer_dv_bitstream bitstream_new(unsigned char* buffer_) @@ -57,41 +57,41 @@ static unsigned long bitstream_get_bits(indexer_dv_bitstream * This, int num) } static int parse_num(indexer_dv_bitstream * b, int numbits) { - return bitstream_get_bits(b, numbits); + return bitstream_get_bits(b, numbits); } static int parse_bcd(indexer_dv_bitstream * b, int n) { - char s[256]; + char s[256]; char * p = s + (n+3)/4; *p-- = 0; - while (n > 4) { - char a; - int v = bitstream_get_bits(b, 4); + while (n > 4) { + char a; + int v = bitstream_get_bits(b, 4); - n -= 4; + n -= 4; a = '0' + v; - if (a > '9') { - bitstream_get_bits(b, n); + if (a > '9') { + bitstream_get_bits(b, n); return -1; - } + } *p-- = a; - } - if (n) { - char a; - int v = bitstream_get_bits(b, n); - a = '0' + v; - if (a > '9') { + } + if (n) { + char a; + int v = bitstream_get_bits(b, n); + a = '0' + v; + if (a > '9') { return -1; - } - *p-- = a; - } + } + *p-- = a; + } - return atol(s); + return atol(s); } typedef struct indexer_dv_context @@ -125,124 +125,124 @@ typedef struct indexer_dv_context static void parse_packet(indexer_dv_context * This, unsigned char * p) { - indexer_dv_bitstream b; - int type = p[0]; + indexer_dv_bitstream b; + int type = p[0]; b = bitstream_new(p + 1); - switch (type) { - case 0x62: // Record date - parse_num(&b, 8); - This->rec_curr_day = parse_bcd(&b, 6); - parse_num(&b, 2); - This->rec_curr_month = parse_bcd(&b, 5); - parse_num(&b, 3); - This->rec_curr_year = parse_bcd(&b, 8); - if (This->rec_curr_year < 25) { - This->rec_curr_year += 2000; - } else { - This->rec_curr_year += 1900; - } - This->got_record_date = 1; - break; - case 0x63: // Record time - This->rec_curr_frame = parse_bcd(&b, 6); - parse_num(&b, 2); - This->rec_curr_second = parse_bcd(&b, 7); - parse_num(&b, 1); - This->rec_curr_minute = parse_bcd(&b, 7); - parse_num(&b, 1); - This->rec_curr_hour = parse_bcd(&b, 6); - This->got_record_time = 1; - break; - } + switch (type) { + case 0x62: // Record date + parse_num(&b, 8); + This->rec_curr_day = parse_bcd(&b, 6); + parse_num(&b, 2); + This->rec_curr_month = parse_bcd(&b, 5); + parse_num(&b, 3); + This->rec_curr_year = parse_bcd(&b, 8); + if (This->rec_curr_year < 25) { + This->rec_curr_year += 2000; + } else { + This->rec_curr_year += 1900; + } + This->got_record_date = 1; + break; + case 0x63: // Record time + This->rec_curr_frame = parse_bcd(&b, 6); + parse_num(&b, 2); + This->rec_curr_second = parse_bcd(&b, 7); + parse_num(&b, 1); + This->rec_curr_minute = parse_bcd(&b, 7); + parse_num(&b, 1); + This->rec_curr_hour = parse_bcd(&b, 6); + This->got_record_time = 1; + break; + } } static void parse_header_block(indexer_dv_context * This, unsigned char* target) { int i; - for (i = 3; i < 80; i += 5) { - if (target[i] != 0xff) { - parse_packet(This, target + i); - } - } + for (i = 3; i < 80; i += 5) { + if (target[i] != 0xff) { + parse_packet(This, target + i); + } + } } static void parse_subcode_blocks( - indexer_dv_context * This, unsigned char* target) + indexer_dv_context * This, unsigned char* target) { int i,j; - for (j = 0; j < 2; j++) { - for (i = 3; i < 80; i += 5) { - if (target[i] != 0xff) { - parse_packet(This, target + i); - } - } - } + for (j = 0; j < 2; j++) { + for (i = 3; i < 80; i += 5) { + if (target[i] != 0xff) { + parse_packet(This, target + i); + } + } + } } static void parse_vaux_blocks( - indexer_dv_context * This, unsigned char* target) + indexer_dv_context * This, unsigned char* target) { int i,j; - for (j = 0; j < 3; j++) { - for (i = 3; i < 80; i += 5) { - if (target[i] != 0xff) { - parse_packet(This, target + i); - } - } - target += 80; - } + for (j = 0; j < 3; j++) { + for (i = 3; i < 80; i += 5) { + if (target[i] != 0xff) { + parse_packet(This, target + i); + } + } + target += 80; + } } static void parse_audio_headers( - indexer_dv_context * This, unsigned char* target) + indexer_dv_context * This, unsigned char* target) { int i; - for(i = 0; i < 9; i++) { - if (target[3] != 0xff) { - parse_packet(This, target + 3); - } - target += 16 * 80; - } + for(i = 0; i < 9; i++) { + if (target[3] != 0xff) { + parse_packet(This, target + 3); + } + target += 16 * 80; + } } static void parse_frame(indexer_dv_context * This, - unsigned char * framebuffer, int isPAL) + unsigned char * framebuffer, int isPAL) { - int numDIFseq = isPAL ? 12 : 10; - unsigned char* target = framebuffer; + int numDIFseq = isPAL ? 12 : 10; + unsigned char* target = framebuffer; int ds; - for (ds = 0; ds < numDIFseq; ds++) { - parse_header_block(This, target); - target += 1 * 80; - parse_subcode_blocks(This, target); - target += 2 * 80; - parse_vaux_blocks(This, target); - target += 3 * 80; - parse_audio_headers(This, target); - target += 144 * 80; - } + for (ds = 0; ds < numDIFseq; ds++) { + parse_header_block(This, target); + target += 1 * 80; + parse_subcode_blocks(This, target); + target += 2 * 80; + parse_vaux_blocks(This, target); + target += 3 * 80; + parse_audio_headers(This, target); + target += 144 * 80; + } } static void inc_frame(int * frame, time_t * t, int isPAL) { - if ((isPAL && *frame >= 25) || (!isPAL && *frame >= 30)) { - fprintf(stderr, "Ouchie: inc_frame: invalid_frameno: %d\n", - *frame); - } - (*frame)++; - if (isPAL && *frame >= 25) { - (*t)++; - *frame = 0; - } else if (!isPAL && *frame >= 30) { - (*t)++; - *frame = 0; - } + if ((isPAL && *frame >= 25) || (!isPAL && *frame >= 30)) { + fprintf(stderr, "Ouchie: inc_frame: invalid_frameno: %d\n", + *frame); + } + (*frame)++; + if (isPAL && *frame >= 25) { + (*t)++; + *frame = 0; + } else if (!isPAL && *frame >= 30) { + (*t)++; + *frame = 0; + } } static void write_index(indexer_dv_context * This, anim_index_entry * entry) @@ -256,36 +256,36 @@ static void fill_gap(indexer_dv_context * This, int isPAL) { int i; - for (i = 0; i < This->fsize; i++) { - if (This->gap_start == This->ref_time_read && - This->gap_frame == This->curr_frame) { - fprintf(stderr, - "indexer_dv::fill_gap: " - "can't seek backwards !\n"); - break; - } - inc_frame(&This->gap_frame, &This->gap_start, isPAL); - } + for (i = 0; i < This->fsize; i++) { + if (This->gap_start == This->ref_time_read && + This->gap_frame == This->curr_frame) { + fprintf(stderr, + "indexer_dv::fill_gap: " + "can't seek backwards !\n"); + break; + } + inc_frame(&This->gap_frame, &This->gap_start, isPAL); + } - while (This->gap_start != This->ref_time_read || + while (This->gap_start != This->ref_time_read || This->gap_frame != This->curr_frame) { - inc_frame(&This->gap_frame, &This->gap_start, isPAL); + inc_frame(&This->gap_frame, &This->gap_start, isPAL); This->frameno_offset++; - } + } - for (i = 0; i < This->fsize; i++) { + for (i = 0; i < This->fsize; i++) { write_index(This, This->backbuffer + i); - } - This->fsize = 0; + } + This->fsize = 0; } static void proc_frame(indexer_dv_context * This, - unsigned char* UNUSED(framebuffer), int isPAL) + unsigned char* UNUSED(framebuffer), int isPAL) { struct tm recDate; time_t t; - if (!This->got_record_date || !This->got_record_time) { + if (!This->got_record_date || !This->got_record_time) { return; } @@ -329,9 +329,9 @@ static void proc_frame(indexer_dv_context * This, } static void indexer_dv_proc_frame(anim_index_builder * idx, - unsigned char * buffer, - int UNUSED(data_size), - struct anim_index_entry * entry) + unsigned char * buffer, + int UNUSED(data_size), + struct anim_index_entry * entry) { int isPAL; @@ -354,7 +354,7 @@ static void indexer_dv_proc_frame(anim_index_builder * idx, int i; fprintf(stderr, "indexer_dv::indexer_dv_proc_frame: " - "backbuffer overrun, emergency flush"); + "backbuffer overrun, emergency flush"); for (i = 0; i < This->fsize; i++) { write_index(This, This->backbuffer+i); @@ -378,8 +378,8 @@ static void indexer_dv_delete(anim_index_builder * idx) void IMB_indexer_dv_new(anim_index_builder * idx) { - indexer_dv_context * rv = MEM_callocN( - sizeof(indexer_dv_context), "index_dv builder context"); + indexer_dv_context * rv = MEM_callocN( + sizeof(indexer_dv_context), "index_dv builder context"); rv->ref_time_read = -1; rv->curr_frame = -1; diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 7b528ed9624..88f6508d356 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -487,7 +487,7 @@ void IMB_exr_add_channel(void *handle, const char *layname, const char *passname } /* only used for writing temp. render results (not image files) */ -void IMB_exr_begin_write(void *handle, const char *filename, int width, int height, int compress) +int IMB_exr_begin_write(void *handle, const char *filename, int width, int height, int compress) { ExrHandle *data= (ExrHandle *)handle; Header header (width, height); @@ -504,8 +504,17 @@ void IMB_exr_begin_write(void *handle, const char *filename, int width, int heig /* header.lineOrder() = DECREASING_Y; this crashes in windows for file read! */ header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.55.1 and newer")); - - data->ofile = new OutputFile(filename, header); + + /* avoid crash/abort when we dont have permission to write here */ + try { + data->ofile = new OutputFile(filename, header); + } + catch (const std::exception &exc) { + std::cerr << "IMB_exr_begin_write: ERROR: " << exc.what() << std::endl; + data->ofile = NULL; + } + + return (data->ofile != NULL); } void IMB_exrtile_begin_write(void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley) diff --git a/source/blender/imbuf/intern/openexr/openexr_multi.h b/source/blender/imbuf/intern/openexr/openexr_multi.h index 3d95bb7c306..58c5e0f2a3e 100644 --- a/source/blender/imbuf/intern/openexr/openexr_multi.h +++ b/source/blender/imbuf/intern/openexr/openexr_multi.h @@ -50,7 +50,7 @@ void * IMB_exr_get_handle (void); void IMB_exr_add_channel (void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect); int IMB_exr_begin_read (void *handle, const char *filename, int *width, int *height); -void IMB_exr_begin_write (void *handle, const char *filename, int width, int height, int compress); +int IMB_exr_begin_write (void *handle, const char *filename, int width, int height, int compress); void IMB_exrtile_begin_write (void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley); void IMB_exr_set_channel (void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect); @@ -75,7 +75,7 @@ void * IMB_exr_get_handle (void) {return NULL;} void IMB_exr_add_channel (void *handle, const char *layname, const char *channame, int xstride, int ystride, float *rect) { (void)handle; (void)layname; (void)channame; (void)xstride; (void)ystride; (void)rect; } int IMB_exr_begin_read (void *handle, const char *filename, int *width, int *height) { (void)handle; (void)filename; (void)width; (void)height; return 0;} -void IMB_exr_begin_write (void *handle, const char *filename, int width, int height, int compress) { (void)handle; (void)filename; (void)width; (void)height; (void)compress; } +int IMB_exr_begin_write (void *handle, const char *filename, int width, int height, int compress) { (void)handle; (void)filename; (void)width; (void)height; (void)compress; return 0;} void IMB_exrtile_begin_write (void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley) { (void)handle; (void)filename; (void)mipmap; (void)width; (void)height; (void)tilex; (void)tiley; } void IMB_exr_set_channel (void *handle, char *layname, const char *channame, int xstride, int ystride, float *rect) { (void)handle; (void)layname; (void)channame; (void)xstride; (void)ystride; (void)rect; } diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 844478e03cb..db2ae3a5114 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -482,7 +482,7 @@ void IMB_rectfill(struct ImBuf *drect, const float col[4]) } -void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2) +void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2) { int i, j; float a; /* alpha */ @@ -509,6 +509,8 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, unsigned char *pixel; unsigned char chr=0, chg=0, chb=0; float fr=0, fg=0, fb=0; + + const int alphaint= FTOCHAR(a); if (a == 1.0f) { chr = FTOCHAR(col[0]); @@ -527,10 +529,13 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, pixel[0] = chr; pixel[1] = chg; pixel[2] = chb; + pixel[3] = 255; } else { + int alphatest; pixel[0] = (char)((fr + ((float)pixel[0]*aich))*255.0f); pixel[1] = (char)((fg + ((float)pixel[1]*aich))*255.0f); pixel[2] = (char)((fb + ((float)pixel[2]*aich))*255.0f); + pixel[3] = (char)((alphatest= ((int)pixel[3] + alphaint)) < 255 ? alphatest : 255); } } } @@ -546,10 +551,13 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, pixel[0] = col[0]; pixel[1] = col[1]; pixel[2] = col[2]; + pixel[3] = 1.0f; } else { + float alphatest; pixel[0] = (col[0]*a) + (pixel[0]*ai); pixel[1] = (col[1]*a) + (pixel[1]*ai); pixel[2] = (col[2]*a) + (pixel[2]*ai); + pixel[3] = (alphatest= (pixel[3] + a)) < 1.0f ? alphatest : 1.0f; } } } diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c index cd660e11f26..b933e6d93ee 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.c @@ -55,7 +55,6 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags) if(ibuf->rect==NULL && ibuf->rect_float) IMB_rect_from_float(ibuf); } - /* TODO. have const char for image write funcs */ return type->save(ibuf, name, flags); } } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 0d4e31cdaf2..ad79771416d 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2216,8 +2216,17 @@ char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fi else buf= MEM_mallocN(sizeof(char)*(length+1), "RNA_string_get_alloc"); +#ifndef NDEBUG + /* safety check to ensure the string is actually set */ + buf[length]= 255; +#endif + RNA_property_string_get(ptr, prop, buf); +#ifndef NDEBUG + BLI_assert(buf[length] == '\0'); +#endif + return buf; } diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 1ba2e32502f..ccb24d7dd9b 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -184,7 +184,11 @@ static void rna_DomainFluidSettings_memory_estimate_get(PointerRNA *ptr, char *v static int rna_DomainFluidSettings_memory_estimate_length(PointerRNA *ptr) { - return 32; +#ifdef DISABLE_ELBEEM + return 0; +#else + return 31; +#endif } static char *rna_FluidSettings_path(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 1220c4f34a1..fd7987c18a2 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -111,7 +111,7 @@ void RNA_api_scene(StructRNA *srna) #ifdef WITH_COLLADA /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */ func= RNA_def_function(srna, "collada_export", "rna_Scene_collada_export"); - parm= RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file."); + RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file."); parm= RNA_def_boolean(func, "selected", 0, "Export only selected", "Export only selected elements."); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 8f3097e5589..7a7debe1bf5 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -591,7 +591,8 @@ static void rna_SpaceTextEditor_text_set(PointerRNA *ptr, PointerRNA value) SpaceText *st= (SpaceText*)(ptr->data); st->text= value.data; - st->top= 0; + + WM_main_add_notifier(NC_TEXT|NA_SELECTED, st->text); } static void rna_SpaceTextEditor_updateEdited(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 93adf808f83..4c07a89a42f 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -680,20 +680,14 @@ static void rna_wmKeyMapItem_name_get(PointerRNA *ptr, char *value) { wmKeyMapItem *kmi= ptr->data; wmOperatorType *ot= WM_operatortype_find(kmi->idname, 1); - - if (ot) - strcpy(value, ot->name); + strcpy(value, ot ? ot->name : kmi->idname); } static int rna_wmKeyMapItem_name_length(PointerRNA *ptr) { wmKeyMapItem *kmi= ptr->data; wmOperatorType *ot= WM_operatortype_find(kmi->idname, 1); - - if (ot) - return strlen(ot->name); - else - return 0; + return strlen(ot ? ot->name : kmi->idname); } static int rna_KeyMapItem_userdefined_get(PointerRNA *ptr) @@ -1652,7 +1646,9 @@ static void rna_def_keyconfig(BlenderRNA *brna) RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_idname_get", "rna_wmKeyMapItem_idname_length", "rna_wmKeyMapItem_idname_set"); RNA_def_struct_name_property(srna, prop); RNA_def_property_update(prop, 0, "rna_KeyMapItem_update"); - + + /* this is infact the operator name, but if the operator can't be found we + * fallback on the operator ID */ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Name", "Name of operator to call on input event"); diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 09432e0b316..ae8069cf3c5 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -52,11 +52,9 @@ static int Buffer_len(Buffer *self); static PyObject *Buffer_item(Buffer *self, int i); static PyObject *Buffer_slice(Buffer *self, int begin, int end); static int Buffer_ass_item(Buffer *self, int i, PyObject *v); -static int Buffer_ass_slice(Buffer *self, int begin, int end, - PyObject *seq); +static int Buffer_ass_slice(Buffer *self, int begin, int end, PyObject *seq); static PyObject *Buffer_subscript(Buffer *self, PyObject *item); -static int Buffer_ass_subscript(Buffer *self, PyObject *item, - PyObject *value); +static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value); static PySequenceMethods Buffer_SeqMethods = { (lenfunc) Buffer_len, /*sq_length */ diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 81aea8571f8..b7e67ec5a93 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -208,77 +208,34 @@ PyObject *PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...) return item; } -/* returns the exception string as a new PyUnicode object, depends on external StringIO module */ +/* returns the exception string as a new PyUnicode object, depends on external traceback module */ PyObject *PyC_ExceptionBuffer(void) { - PyObject *stdout_backup = PySys_GetObject("stdout"); /* borrowed */ - PyObject *stderr_backup = PySys_GetObject("stderr"); /* borrowed */ - PyObject *string_io = NULL; - PyObject *string_io_buf = NULL; - PyObject *string_io_mod= NULL; - PyObject *string_io_getvalue= NULL; - - PyObject *error_type, *error_value, *error_traceback; - - if (!PyErr_Occurred()) - return NULL; - - PyErr_Fetch(&error_type, &error_value, &error_traceback); - - PyErr_Clear(); - - /* import io - * string_io = io.StringIO() - */ - - if(! (string_io_mod= PyImport_ImportModule("io")) ) { + PyObject *traceback_mod= NULL; + PyObject *format_tb_func= NULL; + PyObject *ret= NULL; + + if(! (traceback_mod= PyImport_ImportModule("traceback")) ) { goto error_cleanup; } - else if (! (string_io = PyObject_CallMethod(string_io_mod, (char *)"StringIO", NULL))) { + else if (! (format_tb_func= PyObject_GetAttrString(traceback_mod, "format_exc"))) { goto error_cleanup; } - else if (! (string_io_getvalue= PyObject_GetAttrString(string_io, "getvalue"))) { - goto error_cleanup; + + ret= PyObject_CallObject(format_tb_func, NULL); + + if(ret == Py_None) { + Py_DECREF(ret); + ret= NULL; } - - Py_INCREF(stdout_backup); // since these were borrowed we dont want them freed when replaced. - Py_INCREF(stderr_backup); - - PySys_SetObject("stdout", string_io); // both of these are free'd when restoring - PySys_SetObject("stderr", string_io); - - PyErr_Restore(error_type, error_value, error_traceback); - PyErr_Print(); /* print the error */ - PyErr_Clear(); - - string_io_buf = PyObject_CallObject(string_io_getvalue, NULL); - - PySys_SetObject("stdout", stdout_backup); - PySys_SetObject("stderr", stderr_backup); - - Py_DECREF(stdout_backup); /* now sys owns the ref again */ - Py_DECREF(stderr_backup); - - Py_DECREF(string_io_mod); - Py_DECREF(string_io_getvalue); - Py_DECREF(string_io); /* free the original reference */ - - PyErr_Clear(); - return string_io_buf; - - + error_cleanup: /* could not import the module so print the error and close */ - Py_XDECREF(string_io_mod); - Py_XDECREF(string_io); - - PyErr_Restore(error_type, error_value, error_traceback); - PyErr_Print(); /* print the error */ - PyErr_Clear(); - - return NULL; -} + Py_XDECREF(traceback_mod); + Py_XDECREF(format_tb_func); + return ret; +} /* string conversion, escape non-unicode chars, coerce must be set to NULL */ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index 26d9ca76e3f..e7e46160199 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -42,9 +42,10 @@ static PyTypeObject BlenderAppCbType; static PyStructSequence_Field app_cb_info_fields[]= { {(char *)"render_pre", NULL}, {(char *)"render_post", NULL}, - {(char *)"load_pre", NULL}, + {(char *)"render_stats", NULL}, + {(char *)"load_pre", NULL}, {(char *)"load_post", NULL}, - {(char *)"save_pre", NULL}, + {(char *)"save_pre", NULL}, {(char *)"save_post", NULL}, {NULL} }; diff --git a/source/blender/python/intern/bpy_intern_string.c b/source/blender/python/intern/bpy_intern_string.c index 6fc861b2a0d..7c80653496f 100644 --- a/source/blender/python/intern/bpy_intern_string.c +++ b/source/blender/python/intern/bpy_intern_string.c @@ -40,7 +40,7 @@ PyObject *bpy_intern_str___slots__; void bpy_intern_string_init(void) { bpy_intern_str_register= PyUnicode_FromString("register"); - bpy_intern_str_unregister= PyUnicode_FromString("unregister");; + bpy_intern_str_unregister= PyUnicode_FromString("unregister"); bpy_intern_str_bl_rna= PyUnicode_FromString("bl_rna"); bpy_intern_str_order= PyUnicode_FromString("order"); bpy_intern_str_attr= PyUnicode_FromString("attr"); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index e1c38a82142..d10c8c843e8 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1298,7 +1298,9 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) { int subtype= RNA_property_subtype(prop); const char *buf; - buf= RNA_property_string_get_alloc(ptr, prop, NULL, -1); + char buf_fixed[32]; + + buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed)); #ifdef USE_STRING_COERCE /* only file paths get special treatment, they may contain non utf-8 chars */ if(ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) { @@ -1310,7 +1312,9 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) #else // USE_STRING_COERCE ret= PyUnicode_FromString(buf); #endif // USE_STRING_COERCE - MEM_freeN((void *)buf); + if(buf_fixed != buf) { + MEM_freeN((void *)buf); + } break; } case PROP_ENUM: @@ -4627,28 +4631,28 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject /* note: tp_base member is set to &PyType_Type on init */ PyTypeObject pyrna_struct_meta_idprop_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_struct_meta_idprop", /* tp_name */ - sizeof(PyHeapTypeObject), /* tp_basicsize */ // XXX, would be PyTypeObject, but subtypes of Type must be PyHeapTypeObject's - 0, /* tp_itemsize */ + "bpy_struct_meta_idprop", /* tp_name */ + sizeof(PyHeapTypeObject), /* tp_basicsize */ // XXX, would be PyTypeObject, but subtypes of Type must be PyHeapTypeObject's + 0, /* tp_itemsize */ /* methods */ - NULL, /* tp_dealloc */ + NULL, /* tp_dealloc */ NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ - NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* deprecated in python 3.0! */ - NULL, /* tp_repr */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* tp_compare */ /* deprecated in python 3.0! */ + NULL, /* tp_repr */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ - NULL, /* PySequenceMethods *tp_as_sequence; */ - NULL, /* PyMappingMethods *tp_as_mapping; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ - NULL, /* reprfunc tp_str; */ - NULL /*(getattrofunc) pyrna_struct_meta_idprop_getattro*/, /* getattrofunc tp_getattro; */ - (setattrofunc) pyrna_struct_meta_idprop_setattro, /* setattrofunc tp_setattro; */ + NULL, /* hashfunc tp_hash; */ + NULL, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ + NULL /*(getattrofunc) pyrna_struct_meta_idprop_getattro*/, /* getattrofunc tp_getattro; */ + (setattrofunc) pyrna_struct_meta_idprop_setattro, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -4656,7 +4660,7 @@ PyTypeObject pyrna_struct_meta_idprop_Type= { /*** Flags to define presence of optional/expanded features ***/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -4666,7 +4670,7 @@ PyTypeObject pyrna_struct_meta_idprop_Type= { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - NULL, /* richcmpfunc tp_richcompare; */ + NULL, /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ 0, /* long tp_weaklistoffset; */ @@ -4677,9 +4681,9 @@ PyTypeObject pyrna_struct_meta_idprop_Type= { NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - NULL, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -4687,7 +4691,7 @@ PyTypeObject pyrna_struct_meta_idprop_Type= { 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - NULL, /* newfunc tp_new; */ + NULL, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ @@ -4705,45 +4709,45 @@ PyTypeObject pyrna_struct_meta_idprop_Type= { /*-----------------------BPy_StructRNA method def------------------------------*/ PyTypeObject pyrna_struct_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_struct", /* tp_name */ - sizeof(BPy_StructRNA), /* tp_basicsize */ - 0, /* tp_itemsize */ + "bpy_struct", /* tp_name */ + sizeof(BPy_StructRNA), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor) pyrna_struct_dealloc,/* tp_dealloc */ NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ - NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ - (reprfunc) pyrna_struct_repr, /* tp_repr */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + (reprfunc) pyrna_struct_repr, /* tp_repr */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ - &pyrna_struct_as_sequence, /* PySequenceMethods *tp_as_sequence; */ - &pyrna_struct_as_mapping, /* PyMappingMethods *tp_as_mapping; */ + &pyrna_struct_as_sequence, /* PySequenceMethods *tp_as_sequence; */ + &pyrna_struct_as_mapping, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - (hashfunc) pyrna_struct_hash, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ + (hashfunc) pyrna_struct_hash, /* hashfunc tp_hash; */ + NULL, /* ternaryfunc tp_call; */ (reprfunc) pyrna_struct_str, /* reprfunc tp_str; */ - (getattrofunc) pyrna_struct_getattro, /* getattrofunc tp_getattro; */ - (setattrofunc) pyrna_struct_setattro, /* setattrofunc tp_setattro; */ + (getattrofunc) pyrna_struct_getattro, /* getattrofunc tp_getattro; */ + (setattrofunc) pyrna_struct_setattro, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ /*** Flags to define presence of optional/expanded features ***/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* long tp_flags; */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ #ifdef USE_PYRNA_STRUCT_REFERENCE - (traverseproc) pyrna_struct_traverse, /* traverseproc tp_traverse; */ + (traverseproc) pyrna_struct_traverse, /* traverseproc tp_traverse; */ /* delete references to contained objects */ - (inquiry)pyrna_struct_clear, /* inquiry tp_clear; */ + (inquiry)pyrna_struct_clear, /* inquiry tp_clear; */ #else NULL, /* traverseproc tp_traverse; */ @@ -4753,11 +4757,11 @@ PyTypeObject pyrna_struct_Type= { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - (richcmpfunc)pyrna_struct_richcmp, /* richcmpfunc tp_richcompare; */ + (richcmpfunc)pyrna_struct_richcmp, /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ #ifdef USE_WEAKREFS - offsetof(BPy_StructRNA, in_weakreflist), /* long tp_weaklistoffset; */ + offsetof(BPy_StructRNA, in_weakreflist), /* long tp_weaklistoffset; */ #else 0, #endif @@ -4767,9 +4771,9 @@ PyTypeObject pyrna_struct_Type= { NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - pyrna_struct_methods, /* struct PyMethodDef *tp_methods; */ + pyrna_struct_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - pyrna_struct_getseters, /* struct PyGetSetDef *tp_getset; */ + pyrna_struct_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -4777,7 +4781,7 @@ PyTypeObject pyrna_struct_Type= { 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - pyrna_struct_new, /* newfunc tp_new; */ + pyrna_struct_new, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ @@ -4794,32 +4798,32 @@ PyTypeObject pyrna_struct_Type= { /*-----------------------BPy_PropertyRNA method def------------------------------*/ PyTypeObject pyrna_prop_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_prop", /* tp_name */ - sizeof(BPy_PropertyRNA), /* tp_basicsize */ - 0, /* tp_itemsize */ + "bpy_prop", /* tp_name */ + sizeof(BPy_PropertyRNA), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor) pyrna_prop_dealloc, /* tp_dealloc */ - NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ - (reprfunc) pyrna_prop_repr, /* tp_repr */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + (reprfunc) pyrna_prop_repr, /* tp_repr */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ - NULL, /* PySequenceMethods *tp_as_sequence; */ - NULL, /* PyMappingMethods *tp_as_mapping; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - (hashfunc) pyrna_prop_hash, /* hashfunc tp_hash; */ + (hashfunc) pyrna_prop_hash, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ (reprfunc) pyrna_prop_str, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - NULL, /* getattrofunc tp_getattro; */ - NULL, /* setattrofunc tp_setattro; */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -4827,7 +4831,7 @@ PyTypeObject pyrna_prop_Type= { /*** Flags to define presence of optional/expanded features ***/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -4848,11 +4852,11 @@ PyTypeObject pyrna_prop_Type= { /*** Added in release 2.2 ***/ /* Iterators */ - NULL, /* getiterfunc tp_iter; */ + NULL, /* getiterfunc tp_iter; */ NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - pyrna_prop_methods, /* struct PyMethodDef *tp_methods; */ + pyrna_prop_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ pyrna_prop_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ @@ -4862,7 +4866,7 @@ PyTypeObject pyrna_prop_Type= { 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - pyrna_prop_new, /* newfunc tp_new; */ + pyrna_prop_new, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ @@ -4884,34 +4888,34 @@ PyTypeObject pyrna_prop_array_Type= { /* methods */ (destructor)pyrna_prop_array_dealloc, /* tp_dealloc */ NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ + NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ NULL,/* subclassed */ /* tp_repr */ /* Method suites for standard classes */ - &pyrna_prop_array_as_number, /* PyNumberMethods *tp_as_number; */ - &pyrna_prop_array_as_sequence, /* PySequenceMethods *tp_as_sequence; */ - &pyrna_prop_array_as_mapping, /* PyMappingMethods *tp_as_mapping; */ + &pyrna_prop_array_as_number, /* PyNumberMethods *tp_as_number; */ + &pyrna_prop_array_as_sequence, /* PySequenceMethods *tp_as_sequence; */ + &pyrna_prop_array_as_mapping, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ + NULL, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - (getattrofunc) pyrna_prop_array_getattro, /* getattrofunc tp_getattro; */ - NULL, /* setattrofunc tp_setattro; */ + (getattrofunc) pyrna_prop_array_getattro, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ /*** Flags to define presence of optional/expanded features ***/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -4921,7 +4925,7 @@ PyTypeObject pyrna_prop_array_Type= { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */ + NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ #ifdef USE_WEAKREFS @@ -4935,22 +4939,22 @@ PyTypeObject pyrna_prop_array_Type= { NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - pyrna_prop_array_methods, /* struct PyMethodDef *tp_methods; */ + pyrna_prop_array_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ - &pyrna_prop_Type, /* struct _typeobject *tp_base; */ + NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ + &pyrna_prop_Type, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ NULL, /* descrsetfunc tp_descr_set; */ 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - NULL, /* newfunc tp_new; */ + NULL, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ NULL, /* inquiry tp_is_gc; */ - NULL, /* PyObject *tp_bases; */ + NULL, /* PyObject *tp_bases; */ /* method resolution order */ NULL, /* PyObject *tp_mro; */ NULL, /* PyObject *tp_cache; */ @@ -4961,32 +4965,32 @@ PyTypeObject pyrna_prop_array_Type= { PyTypeObject pyrna_prop_collection_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_prop_collection", /* tp_name */ - sizeof(BPy_PropertyRNA), /* tp_basicsize */ - 0, /* tp_itemsize */ + "bpy_prop_collection", /* tp_name */ + sizeof(BPy_PropertyRNA), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor)pyrna_prop_dealloc, /* tp_dealloc */ NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ + NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ NULL, /* subclassed */ /* tp_repr */ /* Method suites for standard classes */ &pyrna_prop_collection_as_number, /* PyNumberMethods *tp_as_number; */ - &pyrna_prop_collection_as_sequence, /* PySequenceMethods *tp_as_sequence; */ - &pyrna_prop_collection_as_mapping, /* PyMappingMethods *tp_as_mapping; */ + &pyrna_prop_collection_as_sequence, /* PySequenceMethods *tp_as_sequence; */ + &pyrna_prop_collection_as_mapping, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ + NULL, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - (getattrofunc) pyrna_prop_collection_getattro, /* getattrofunc tp_getattro; */ - (setattrofunc) pyrna_prop_collection_setattro, /* setattrofunc tp_setattro; */ + (getattrofunc) pyrna_prop_collection_getattro, /* getattrofunc tp_getattro; */ + (setattrofunc) pyrna_prop_collection_setattro, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -4994,7 +4998,7 @@ PyTypeObject pyrna_prop_collection_Type= { /*** Flags to define presence of optional/expanded features ***/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -5008,33 +5012,33 @@ PyTypeObject pyrna_prop_collection_Type= { /*** weak reference enabler ***/ #ifdef USE_WEAKREFS - offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */ + offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */ #else 0, #endif /*** Added in release 2.2 ***/ /* Iterators */ - (getiterfunc)pyrna_prop_collection_iter, /* getiterfunc tp_iter; */ + (getiterfunc)pyrna_prop_collection_iter, /* getiterfunc tp_iter; */ NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - pyrna_prop_collection_methods, /* struct PyMethodDef *tp_methods; */ + pyrna_prop_collection_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ - &pyrna_prop_Type, /* struct _typeobject *tp_base; */ + NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ + &pyrna_prop_Type, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ NULL, /* descrsetfunc tp_descr_set; */ 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - NULL, /* newfunc tp_new; */ + NULL, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ NULL, /* inquiry tp_is_gc; */ - NULL, /* PyObject *tp_bases; */ + NULL, /* PyObject *tp_bases; */ /* method resolution order */ NULL, /* PyObject *tp_mro; */ NULL, /* PyObject *tp_cache; */ @@ -5046,32 +5050,32 @@ PyTypeObject pyrna_prop_collection_Type= { /* only for add/remove/move methods */ static PyTypeObject pyrna_prop_collection_idprop_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_prop_collection_idprop", /* tp_name */ - sizeof(BPy_PropertyRNA), /* tp_basicsize */ - 0, /* tp_itemsize */ + "bpy_prop_collection_idprop", /* tp_name */ + sizeof(BPy_PropertyRNA), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor)pyrna_prop_dealloc, /* tp_dealloc */ NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ + NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ - NULL, /* subclassed */ /* tp_repr */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + NULL, /* subclassed */ /* tp_repr */ /* Method suites for standard classes */ - NULL, /* PyNumberMethods *tp_as_number; */ - NULL, /* PySequenceMethods *tp_as_sequence; */ - NULL, /* PyMappingMethods *tp_as_mapping; */ + NULL, /* PyNumberMethods *tp_as_number; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ + NULL, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - NULL, /* getattrofunc tp_getattro; */ - NULL, /* setattrofunc tp_setattro; */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -5079,7 +5083,7 @@ static PyTypeObject pyrna_prop_collection_idprop_Type= { /*** Flags to define presence of optional/expanded features ***/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -5093,33 +5097,33 @@ static PyTypeObject pyrna_prop_collection_idprop_Type= { /*** weak reference enabler ***/ #ifdef USE_WEAKREFS - offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */ + offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */ #else 0, #endif /*** Added in release 2.2 ***/ /* Iterators */ - NULL, /* getiterfunc tp_iter; */ + NULL, /* getiterfunc tp_iter; */ NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ pyrna_prop_collection_idprop_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ - &pyrna_prop_collection_Type, /* struct _typeobject *tp_base; */ + NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ + &pyrna_prop_collection_Type,/* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ NULL, /* descrsetfunc tp_descr_set; */ 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - NULL, /* newfunc tp_new; */ + NULL, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ NULL, /* inquiry tp_is_gc; */ - NULL, /* PyObject *tp_bases; */ + NULL, /* PyObject *tp_bases; */ /* method resolution order */ NULL, /* PyObject *tp_mro; */ NULL, /* PyObject *tp_cache; */ @@ -5131,32 +5135,32 @@ static PyTypeObject pyrna_prop_collection_idprop_Type= { /*-----------------------BPy_PropertyRNA method def------------------------------*/ PyTypeObject pyrna_func_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_func", /* tp_name */ - sizeof(BPy_FunctionRNA), /* tp_basicsize */ - 0, /* tp_itemsize */ + "bpy_func", /* tp_name */ + sizeof(BPy_FunctionRNA), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ - NULL, /* tp_dealloc */ - NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ + NULL, /* tp_dealloc */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ - (reprfunc) pyrna_func_repr, /* tp_repr */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + (reprfunc) pyrna_func_repr, /* tp_repr */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ - NULL, /* PySequenceMethods *tp_as_sequence; */ - NULL, /* PyMappingMethods *tp_as_mapping; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ - (ternaryfunc)pyrna_func_call, /* ternaryfunc tp_call; */ - NULL, /* reprfunc tp_str; */ + NULL, /* hashfunc tp_hash; */ + (ternaryfunc)pyrna_func_call, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - NULL, /* getattrofunc tp_getattro; */ - NULL, /* setattrofunc tp_setattro; */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -5164,7 +5168,7 @@ PyTypeObject pyrna_func_Type= { /*** Flags to define presence of optional/expanded features ***/ Py_TPFLAGS_DEFAULT, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -5174,7 +5178,7 @@ PyTypeObject pyrna_func_Type= { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - NULL, /* richcmpfunc tp_richcompare; */ + NULL, /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ #ifdef USE_WEAKREFS @@ -5185,13 +5189,13 @@ PyTypeObject pyrna_func_Type= { /*** Added in release 2.2 ***/ /* Iterators */ - NULL, /* getiterfunc tp_iter; */ + NULL, /* getiterfunc tp_iter; */ NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - NULL, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -5199,7 +5203,7 @@ PyTypeObject pyrna_func_Type= { 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - NULL, /* newfunc tp_new; */ + NULL, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ @@ -5227,32 +5231,32 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA * PyTypeObject pyrna_prop_collection_iter_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_prop_collection_iter", /* tp_name */ - sizeof(BPy_PropertyCollectionIterRNA), /* tp_basicsize */ - 0, /* tp_itemsize */ + "bpy_prop_collection_iter", /* tp_name */ + sizeof(BPy_PropertyCollectionIterRNA), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor)pyrna_prop_collection_iter_dealloc, /* tp_dealloc */ NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ + NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ NULL,/* subclassed */ /* tp_repr */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ - NULL, /* PySequenceMethods *tp_as_sequence; */ - NULL, /* PyMappingMethods *tp_as_mapping; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ + NULL, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - PyObject_GenericGetAttr, /* getattrofunc tp_getattro; */ - NULL, /* setattrofunc tp_setattro; */ + PyObject_GenericGetAttr, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -5260,7 +5264,7 @@ PyTypeObject pyrna_prop_collection_iter_Type= { /*** Flags to define presence of optional/expanded features ***/ Py_TPFLAGS_DEFAULT, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -5274,19 +5278,19 @@ PyTypeObject pyrna_prop_collection_iter_Type= { /*** weak reference enabler ***/ #ifdef USE_WEAKREFS - offsetof(BPy_PropertyCollectionIterRNA, in_weakreflist), /* long tp_weaklistoffset; */ + offsetof(BPy_PropertyCollectionIterRNA, in_weakreflist), /* long tp_weaklistoffset; */ #else 0, #endif /*** Added in release 2.2 ***/ /* Iterators */ - PyObject_SelfIter, /* getiterfunc tp_iter; */ - (iternextfunc) pyrna_prop_collection_iter_next, /* iternextfunc tp_iternext; */ + PyObject_SelfIter, /* getiterfunc tp_iter; */ + (iternextfunc) pyrna_prop_collection_iter_next, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - NULL, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -5294,12 +5298,12 @@ PyTypeObject pyrna_prop_collection_iter_Type= { 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - NULL, /* newfunc tp_new; */ + NULL, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ NULL, /* inquiry tp_is_gc; */ - NULL, /* PyObject *tp_bases; */ + NULL, /* PyObject *tp_bases; */ /* method resolution order */ NULL, /* PyObject *tp_mro; */ NULL, /* PyObject *tp_cache; */ diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 0736bed4faf..97ffcd95473 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -227,8 +227,8 @@ void RE_SetReports(struct Render *re, struct ReportList *reports); /* main preview render call */ void RE_PreviewRender(struct Render *re, struct Main *bmain, struct Scene *scene); -void RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode); -void RE_WriteRenderResult(RenderResult *rr, const char *filename, int compress); +int RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode); +int RE_WriteRenderResult(struct ReportList *reports, RenderResult *rr, const char *filename, int compress); struct RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty); extern const float default_envmap_layout[]; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 0d5f8c77f6b..49e5e7b989d 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -173,6 +173,9 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs) else fprintf(stdout, "Sce: %s Ve:%d Fa:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->totlamp); } + + BLI_exec_cb(G.main, NULL, BLI_CB_EVT_RENDER_STATS); + fputc('\n', stdout); fflush(stdout); } @@ -638,9 +641,9 @@ static RenderResult *new_render_result(Render *re, rcti *partrct, int crop, int render_layer_add_pass(rr, rl, 3, SCE_PASS_REFRACT); if(srl->passflag & SCE_PASS_INDEXOB) render_layer_add_pass(rr, rl, 1, SCE_PASS_INDEXOB); - if(srl->passflag & SCE_PASS_INDEXMA) - render_layer_add_pass(rr, rl, 1, SCE_PASS_INDEXMA); - if(srl->passflag & SCE_PASS_MIST) + if(srl->passflag & SCE_PASS_INDEXMA) + render_layer_add_pass(rr, rl, 1, SCE_PASS_INDEXMA); + if(srl->passflag & SCE_PASS_MIST) render_layer_add_pass(rr, rl, 1, SCE_PASS_MIST); if(rl->passflag & SCE_PASS_RAYHITS) render_layer_add_pass(rr, rl, 4, SCE_PASS_RAYHITS); @@ -824,11 +827,12 @@ static char *make_pass_name(RenderPass *rpass, int chan) /* filename already made absolute */ /* called from within UI, saves both rendered result as a file-read result */ -void RE_WriteRenderResult(RenderResult *rr, const char *filename, int compress) +int RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *filename, int compress) { RenderLayer *rl; RenderPass *rpass; void *exrhandle= IMB_exr_get_handle(); + int success; BLI_make_existing_file(filename); @@ -864,11 +868,20 @@ void RE_WriteRenderResult(RenderResult *rr, const char *filename, int compress) } } } - - IMB_exr_begin_write(exrhandle, filename, rr->rectx, rr->recty, compress); - - IMB_exr_write_channels(exrhandle); + + /* when the filename has no permissions, this can fail */ + if(IMB_exr_begin_write(exrhandle, filename, rr->rectx, rr->recty, compress)) { + IMB_exr_write_channels(exrhandle); + success= TRUE; + } + else { + /* TODO, get the error from openexr's exception */ + BKE_report(reports, RPT_ERROR, "Error Writing Render Result, see console"); + success= FALSE; + } IMB_exr_close(exrhandle); + + return success; } /* callbacks for RE_MultilayerConvert */ @@ -992,9 +1005,10 @@ static int read_render_result_from_file(const char *filename, RenderResult *rr) } /* only for temp buffer files, makes exact copy of render result */ -static void read_render_result(Render *re, int sample) +static int read_render_result(Render *re, int sample) { char str[FILE_MAX]; + int success; BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); @@ -1004,10 +1018,18 @@ static void read_render_result(Render *re, int sample) render_unique_exr_name(re, str, sample); printf("read exr tmp file: %s\n", str); - if(!read_render_result_from_file(str, re->result)) + if(read_render_result_from_file(str, re->result)) { + success= TRUE; + } + else { printf("cannot read: %s\n", str); + success= FALSE; + + } BLI_rw_mutex_unlock(&re->resultmutex); + + return success; } /* *************************************************** */ @@ -2981,7 +3003,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, c if(re->r.imtype==R_MULTILAYER) { if(re->result) { - RE_WriteRenderResult(re->result, name, scene->r.quality); + RE_WriteRenderResult(re->reports, re->result, name, scene->r.quality); printf("Saved: %s", name); } } @@ -3198,7 +3220,7 @@ void RE_PreviewRender(Render *re, Main *bmain, Scene *sce) /* note; repeated win/disprect calc... solve that nicer, also in compo */ /* only the temp file! */ -void RE_ReadRenderResult(Scene *scene, Scene *scenode) +int RE_ReadRenderResult(Scene *scene, Scene *scenode) { Render *re; int winx, winy; @@ -3232,7 +3254,7 @@ void RE_ReadRenderResult(Scene *scene, Scene *scenode) RE_InitState(re, NULL, &scene->r, NULL, winx, winy, &disprect); re->scene= scene; - read_render_result(re, 0); + return read_render_result(re, 0); } void RE_set_max_threads(int threads) diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 7f921d21041..30632586b04 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -282,10 +282,10 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) else if(ok1==0 || ok2==0) return; /* at least 1 visible interesction point */ - if(t1<0.0f && t2<0.0f) return; + if(t1<0.0 && t2<0.0) return; - if(t1<0.0f) t1= 0.0f; - if(t2<0.0f) t2= 0.0f; + if(t1<0.0) t1= 0.0; + if(t2<0.0) t2= 0.0; if(t1==t2) return; @@ -423,8 +423,8 @@ float fresnel_fac(float *view, float *vn, float grad, float fac) static double saacos_d(double fac) { - if(fac<= -1.0f) return M_PI; - else if(fac>=1.0f) return 0.0; + if(fac<= -1.0) return M_PI; + else if(fac>=1.0) return 0.0; else return acos(fac); } @@ -590,7 +590,7 @@ static float CookTorr_Spec(float *n, float *l, float *v, int hard, int tangent) i= spec(nh, hard); - i= i/(0.1+nv); + i= i/(0.1f+nv); return i; } @@ -896,7 +896,7 @@ static void ramp_diffuse_result(float *diff, ShadeInput *shi) if(ma->ramp_col) { if(ma->rampin_col==MA_RAMP_IN_RESULT) { - fac= 0.3*diff[0] + 0.58*diff[1] + 0.12*diff[2]; + fac= 0.3f*diff[0] + 0.58f*diff[1] + 0.12f*diff[2]; do_colorband(ma->ramp_col, fac, col); /* blending method */ @@ -926,7 +926,7 @@ static void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, floa /* input */ switch(ma->rampin_col) { case MA_RAMP_IN_ENERGY: - fac= 0.3*r + 0.58*g + 0.12*b; + fac= 0.3f*r + 0.58f*g + 0.12f*b; break; case MA_RAMP_IN_SHADER: fac= is; @@ -966,7 +966,7 @@ static void ramp_spec_result(float *specr, float *specg, float *specb, ShadeInpu float fac; if(ma->ramp_spec && (ma->rampin_spec==MA_RAMP_IN_RESULT)) { - fac= 0.3*(*specr) + 0.58*(*specg) + 0.12*(*specb); + fac= 0.3f*(*specr) + 0.58f*(*specg) + 0.12f*(*specb); do_colorband(ma->ramp_spec, fac, col); /* blending method */ @@ -1213,7 +1213,7 @@ float lamp_get_visibility(LampRen *lar, float *co, float *lv, float *dist) } } } - if (visifac <= 0.001) visifac = 0.0f; + if (visifac <= 0.001f) visifac = 0.0f; return visifac; } } @@ -1231,7 +1231,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int view= shi->view; - if (lar->energy == 0.0) return; + if (lar->energy == 0.0f) return; /* only shadow lamps shouldn't affect shadow-less materials at all */ if ((lar->mode & LA_ONLYSHADOW) && (!(ma->mode & MA_SHADOW) || !(R.r.mode & R_SHADOW))) return; @@ -1359,7 +1359,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int /* 'is' is diffuse */ if((ma->shade_flag & MA_CUBIC) && is>0.0f && is<1.0f) - is= 3.0*is*is - 2.0*is*is*is; // nicer termination of shades + is= 3.0f*is*is - 2.0f*is*is*is; // nicer termination of shades i= is*phongcorr; @@ -1388,7 +1388,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int lamp_get_shadow(lar, shi, inp, shadfac, shi->depth); /* warning, here it skips the loop */ - if((lar->mode & LA_ONLYSHADOW) && i>0.0) { + if((lar->mode & LA_ONLYSHADOW) && i>0.0f) { shadfac[3]= i*lar->energy*(1.0f-shadfac[3]); shr->shad[0] -= shadfac[3]*shi->r*(1.0f-lashdw[0]); @@ -1448,7 +1448,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int t= vn[0]*lv[0]+vn[1]*lv[1]+vn[2]*lv[2]; if(lar->type==LA_HEMI) { - t= 0.5*t+0.5; + t= 0.5f*t+0.5f; } t= shadfac[3]*shi->spec*spec(t, shi->har); diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 04e4ce2c647..925f8529dfa 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -4115,13 +4115,13 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas add_transp_obindex(rlpp[a], od, obr->ob); } } - if(addpassflag & SCE_PASS_INDEXMA) { - ObjectRen *obr= R.objectinstance[zrow[totface-1].obi].obr; - if(obr->ob) { - for(a= 0; aob); - } - } + if(addpassflag & SCE_PASS_INDEXMA) { + ObjectRen *obr= R.objectinstance[zrow[totface-1].obi].obr; + if(obr->ob) { + for(a= 0; aob); + } + } /* for each mask-sample we alpha-under colors. then in end it's added using filter */ memset(samp_shr, 0, sizeof(ShadeResult)*osa); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a4efa8fff84..0e0203543a4 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -108,21 +108,28 @@ static GHash *global_ops_hash= NULL; wmOperatorType *WM_operatortype_find(const char *idname, int quiet) { - wmOperatorType *ot; - - char idname_bl[OP_MAX_TYPENAME]; // XXX, needed to support python style names without the _OT_ syntax - WM_operator_bl_idname(idname_bl, idname); + if(idname[0]) { + wmOperatorType *ot; + + /* needed to support python style names without the _OT_ syntax */ + char idname_bl[OP_MAX_TYPENAME]; + WM_operator_bl_idname(idname_bl, idname); - if (idname_bl[0]) { ot= BLI_ghash_lookup(global_ops_hash, idname_bl); if(ot) { return ot; } + + if(!quiet) { + printf("search for unknown operator '%s', '%s'\n", idname_bl, idname); + } } - - if(!quiet) - printf("search for unknown operator %s, %s\n", idname_bl, idname); - + else { + if(!quiet) { + printf("search for empty operator\n"); + } + } + return NULL; } @@ -1259,11 +1266,12 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar split = uiLayoutSplit(layout, 0, 0); col = uiLayoutColumn(split, 0); uiItemL(col, "Links", ICON_NONE); - uiItemStringO(col, "Donations", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment/"); - uiItemStringO(col, "Release Log", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-259/"); + uiItemStringO(col, "Donations", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment"); + uiItemStringO(col, "Credits", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/credits"); + uiItemStringO(col, "Release Log", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-259"); uiItemStringO(col, "Manual", ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.5/Manual"); - uiItemStringO(col, "Blender Website", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/"); - uiItemStringO(col, "User Community", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community/"); // + uiItemStringO(col, "Blender Website", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org"); + uiItemStringO(col, "User Community", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community"); if(strcmp(STRINGIFY(BLENDER_VERSION_CYCLE), "release")==0) { BLI_snprintf(url, sizeof(url), "http://www.blender.org/documentation/blender_python_api_%d_%d" STRINGIFY(BLENDER_VERSION_CHAR) "_release", BLENDER_VERSION/100, BLENDER_VERSION%100); } diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h index 67a2279d824..7e9a57a0fe7 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h @@ -51,197 +51,195 @@ /** Base Class for Blender specific inputdevices. Blender specific inputdevices are used when the gameengine is running in embedded mode instead of standalone mode. */ -class BL_BlenderInputDevice : public SCA_IInputDevice +class BL_BlenderInputDevice : public SCA_IInputDevice { // this map is Blender specific: a conversion between blender and ketsji enums std::map m_reverseKeyTranslateTable; public: - BL_BlenderInputDevice() - { - - /* The reverse table. In order to not confuse ourselves, we */ - /* immediately convert all events that come in to KX codes. */ - m_reverseKeyTranslateTable[LEFTMOUSE ] = KX_LEFTMOUSE ; - m_reverseKeyTranslateTable[MIDDLEMOUSE ] = KX_MIDDLEMOUSE ; - m_reverseKeyTranslateTable[RIGHTMOUSE ] = KX_RIGHTMOUSE ; - m_reverseKeyTranslateTable[WHEELUPMOUSE ] = KX_WHEELUPMOUSE ; - m_reverseKeyTranslateTable[WHEELDOWNMOUSE ] = KX_WHEELDOWNMOUSE ; - m_reverseKeyTranslateTable[MOUSEX ] = KX_MOUSEX ; - m_reverseKeyTranslateTable[MOUSEY ] = KX_MOUSEY ; - - // TIMERS + BL_BlenderInputDevice() + { - m_reverseKeyTranslateTable[TIMER0 ] = KX_TIMER0 ; - m_reverseKeyTranslateTable[TIMER1 ] = KX_TIMER1 ; - m_reverseKeyTranslateTable[TIMER2 ] = KX_TIMER2 ; - - // SYSTEM -#if 0 - /* **** XXX **** */ - m_reverseKeyTranslateTable[KEYBD ] = KX_KEYBD ; - m_reverseKeyTranslateTable[RAWKEYBD ] = KX_RAWKEYBD ; - m_reverseKeyTranslateTable[REDRAW ] = KX_REDRAW ; - m_reverseKeyTranslateTable[INPUTCHANGE ] = KX_INPUTCHANGE ; - m_reverseKeyTranslateTable[QFULL ] = KX_QFULL ; - m_reverseKeyTranslateTable[WINFREEZE ] = KX_WINFREEZE ; - m_reverseKeyTranslateTable[WINTHAW ] = KX_WINTHAW ; - m_reverseKeyTranslateTable[WINCLOSE ] = KX_WINCLOSE ; - m_reverseKeyTranslateTable[WINQUIT ] = KX_WINQUIT ; - m_reverseKeyTranslateTable[Q_FIRSTTIME ] = KX_Q_FIRSTTIME ; - /* **** XXX **** */ -#endif - // standard keyboard - - m_reverseKeyTranslateTable[AKEY ] = KX_AKEY ; - m_reverseKeyTranslateTable[BKEY ] = KX_BKEY ; - m_reverseKeyTranslateTable[CKEY ] = KX_CKEY ; - m_reverseKeyTranslateTable[DKEY ] = KX_DKEY ; - m_reverseKeyTranslateTable[EKEY ] = KX_EKEY ; - m_reverseKeyTranslateTable[FKEY ] = KX_FKEY ; - m_reverseKeyTranslateTable[GKEY ] = KX_GKEY ; -//XXX clean up + /* The reverse table. In order to not confuse ourselves, we */ + /* immediately convert all events that come in to KX codes. */ + m_reverseKeyTranslateTable[LEFTMOUSE ] = KX_LEFTMOUSE; + m_reverseKeyTranslateTable[MIDDLEMOUSE ] = KX_MIDDLEMOUSE; + m_reverseKeyTranslateTable[RIGHTMOUSE ] = KX_RIGHTMOUSE; + m_reverseKeyTranslateTable[WHEELUPMOUSE ] = KX_WHEELUPMOUSE; + m_reverseKeyTranslateTable[WHEELDOWNMOUSE ] = KX_WHEELDOWNMOUSE; + m_reverseKeyTranslateTable[MOUSEX ] = KX_MOUSEX; + m_reverseKeyTranslateTable[MOUSEY ] = KX_MOUSEY; + + // TIMERS + + m_reverseKeyTranslateTable[TIMER0 ] = KX_TIMER0; + m_reverseKeyTranslateTable[TIMER1 ] = KX_TIMER1; + m_reverseKeyTranslateTable[TIMER2 ] = KX_TIMER2; + + // SYSTEM +#if 0 + /* **** XXX **** */ + m_reverseKeyTranslateTable[KEYBD ] = KX_KEYBD; + m_reverseKeyTranslateTable[RAWKEYBD ] = KX_RAWKEYBD; + m_reverseKeyTranslateTable[REDRAW ] = KX_REDRAW; + m_reverseKeyTranslateTable[INPUTCHANGE ] = KX_INPUTCHANGE; + m_reverseKeyTranslateTable[QFULL ] = KX_QFULL; + m_reverseKeyTranslateTable[WINFREEZE ] = KX_WINFREEZE; + m_reverseKeyTranslateTable[WINTHAW ] = KX_WINTHAW; + m_reverseKeyTranslateTable[WINCLOSE ] = KX_WINCLOSE; + m_reverseKeyTranslateTable[WINQUIT ] = KX_WINQUIT; + m_reverseKeyTranslateTable[Q_FIRSTTIME ] = KX_Q_FIRSTTIME; + /* **** XXX **** */ +#endif + // standard keyboard + + m_reverseKeyTranslateTable[AKEY ] = KX_AKEY; + m_reverseKeyTranslateTable[BKEY ] = KX_BKEY; + m_reverseKeyTranslateTable[CKEY ] = KX_CKEY; + m_reverseKeyTranslateTable[DKEY ] = KX_DKEY; + m_reverseKeyTranslateTable[EKEY ] = KX_EKEY; + m_reverseKeyTranslateTable[FKEY ] = KX_FKEY; + m_reverseKeyTranslateTable[GKEY ] = KX_GKEY; + //XXX clean up #ifdef WIN32 #define HKEY 'h' #endif - m_reverseKeyTranslateTable[HKEY ] = KX_HKEY ; -//XXX clean up + m_reverseKeyTranslateTable[HKEY ] = KX_HKEY; + //XXX clean up #ifdef WIN32 #undef HKEY #endif - m_reverseKeyTranslateTable[IKEY ] = KX_IKEY ; - m_reverseKeyTranslateTable[JKEY ] = KX_JKEY ; - m_reverseKeyTranslateTable[KKEY ] = KX_KKEY ; - m_reverseKeyTranslateTable[LKEY ] = KX_LKEY ; - m_reverseKeyTranslateTable[MKEY ] = KX_MKEY ; - m_reverseKeyTranslateTable[NKEY ] = KX_NKEY ; - m_reverseKeyTranslateTable[OKEY ] = KX_OKEY ; - m_reverseKeyTranslateTable[PKEY ] = KX_PKEY ; - m_reverseKeyTranslateTable[QKEY ] = KX_QKEY ; - m_reverseKeyTranslateTable[RKEY ] = KX_RKEY ; - m_reverseKeyTranslateTable[SKEY ] = KX_SKEY ; - m_reverseKeyTranslateTable[TKEY ] = KX_TKEY ; - m_reverseKeyTranslateTable[UKEY ] = KX_UKEY ; - m_reverseKeyTranslateTable[VKEY ] = KX_VKEY ; - m_reverseKeyTranslateTable[WKEY ] = KX_WKEY ; - m_reverseKeyTranslateTable[XKEY ] = KX_XKEY ; - m_reverseKeyTranslateTable[YKEY ] = KX_YKEY ; - m_reverseKeyTranslateTable[ZKEY ] = KX_ZKEY ; - - m_reverseKeyTranslateTable[ZEROKEY ] = KX_ZEROKEY ; - m_reverseKeyTranslateTable[ONEKEY ] = KX_ONEKEY ; - m_reverseKeyTranslateTable[TWOKEY ] = KX_TWOKEY ; - m_reverseKeyTranslateTable[THREEKEY ] = KX_THREEKEY ; - m_reverseKeyTranslateTable[FOURKEY ] = KX_FOURKEY ; - m_reverseKeyTranslateTable[FIVEKEY ] = KX_FIVEKEY ; - m_reverseKeyTranslateTable[SIXKEY ] = KX_SIXKEY ; - m_reverseKeyTranslateTable[SEVENKEY ] = KX_SEVENKEY ; - m_reverseKeyTranslateTable[EIGHTKEY ] = KX_EIGHTKEY ; - m_reverseKeyTranslateTable[NINEKEY ] = KX_NINEKEY ; - - m_reverseKeyTranslateTable[CAPSLOCKKEY ] = KX_CAPSLOCKKEY ; - - m_reverseKeyTranslateTable[LEFTCTRLKEY ] = KX_LEFTCTRLKEY ; - m_reverseKeyTranslateTable[LEFTALTKEY ] = KX_LEFTALTKEY ; - m_reverseKeyTranslateTable[RIGHTALTKEY ] = KX_RIGHTALTKEY ; - m_reverseKeyTranslateTable[RIGHTCTRLKEY ] = KX_RIGHTCTRLKEY ; - m_reverseKeyTranslateTable[RIGHTSHIFTKEY ] = KX_RIGHTSHIFTKEY ; - m_reverseKeyTranslateTable[LEFTSHIFTKEY ] = KX_LEFTSHIFTKEY ; - - m_reverseKeyTranslateTable[ESCKEY ] = KX_ESCKEY ; - m_reverseKeyTranslateTable[TABKEY ] = KX_TABKEY ; - m_reverseKeyTranslateTable[RETKEY ] = KX_RETKEY ; - m_reverseKeyTranslateTable[SPACEKEY ] = KX_SPACEKEY ; - m_reverseKeyTranslateTable[LINEFEEDKEY ] = KX_LINEFEEDKEY ; - m_reverseKeyTranslateTable[BACKSPACEKEY ] = KX_BACKSPACEKEY ; - m_reverseKeyTranslateTable[DELKEY ] = KX_DELKEY ; - m_reverseKeyTranslateTable[SEMICOLONKEY ] = KX_SEMICOLONKEY ; - m_reverseKeyTranslateTable[PERIODKEY ] = KX_PERIODKEY ; - m_reverseKeyTranslateTable[COMMAKEY ] = KX_COMMAKEY ; - m_reverseKeyTranslateTable[QUOTEKEY ] = KX_QUOTEKEY ; - m_reverseKeyTranslateTable[ACCENTGRAVEKEY ] = KX_ACCENTGRAVEKEY ; - m_reverseKeyTranslateTable[MINUSKEY ] = KX_MINUSKEY ; - m_reverseKeyTranslateTable[SLASHKEY ] = KX_SLASHKEY ; - m_reverseKeyTranslateTable[BACKSLASHKEY ] = KX_BACKSLASHKEY ; - m_reverseKeyTranslateTable[EQUALKEY ] = KX_EQUALKEY ; - m_reverseKeyTranslateTable[LEFTBRACKETKEY ] = KX_LEFTBRACKETKEY ; - m_reverseKeyTranslateTable[RIGHTBRACKETKEY ] = KX_RIGHTBRACKETKEY ; - - m_reverseKeyTranslateTable[LEFTARROWKEY ] = KX_LEFTARROWKEY ; - m_reverseKeyTranslateTable[DOWNARROWKEY ] = KX_DOWNARROWKEY ; - m_reverseKeyTranslateTable[RIGHTARROWKEY ] = KX_RIGHTARROWKEY ; - m_reverseKeyTranslateTable[UPARROWKEY ] = KX_UPARROWKEY ; - - m_reverseKeyTranslateTable[PAD2 ] = KX_PAD2 ; - m_reverseKeyTranslateTable[PAD4 ] = KX_PAD4 ; - m_reverseKeyTranslateTable[PAD6 ] = KX_PAD6 ; - m_reverseKeyTranslateTable[PAD8 ] = KX_PAD8 ; - - m_reverseKeyTranslateTable[PAD1 ] = KX_PAD1 ; - m_reverseKeyTranslateTable[PAD3 ] = KX_PAD3 ; - m_reverseKeyTranslateTable[PAD5 ] = KX_PAD5 ; - m_reverseKeyTranslateTable[PAD7 ] = KX_PAD7 ; - m_reverseKeyTranslateTable[PAD9 ] = KX_PAD9 ; + m_reverseKeyTranslateTable[IKEY ] = KX_IKEY; + m_reverseKeyTranslateTable[JKEY ] = KX_JKEY; + m_reverseKeyTranslateTable[KKEY ] = KX_KKEY; + m_reverseKeyTranslateTable[LKEY ] = KX_LKEY; + m_reverseKeyTranslateTable[MKEY ] = KX_MKEY; + m_reverseKeyTranslateTable[NKEY ] = KX_NKEY; + m_reverseKeyTranslateTable[OKEY ] = KX_OKEY; + m_reverseKeyTranslateTable[PKEY ] = KX_PKEY; + m_reverseKeyTranslateTable[QKEY ] = KX_QKEY; + m_reverseKeyTranslateTable[RKEY ] = KX_RKEY; + m_reverseKeyTranslateTable[SKEY ] = KX_SKEY; + m_reverseKeyTranslateTable[TKEY ] = KX_TKEY; + m_reverseKeyTranslateTable[UKEY ] = KX_UKEY; + m_reverseKeyTranslateTable[VKEY ] = KX_VKEY; + m_reverseKeyTranslateTable[WKEY ] = KX_WKEY; + m_reverseKeyTranslateTable[XKEY ] = KX_XKEY; + m_reverseKeyTranslateTable[YKEY ] = KX_YKEY; + m_reverseKeyTranslateTable[ZKEY ] = KX_ZKEY; - m_reverseKeyTranslateTable[PADPERIOD ] = KX_PADPERIOD ; - m_reverseKeyTranslateTable[PADSLASHKEY ] = KX_PADSLASHKEY ; - m_reverseKeyTranslateTable[PADASTERKEY ] = KX_PADASTERKEY ; - - - m_reverseKeyTranslateTable[PAD0 ] = KX_PAD0 ; - m_reverseKeyTranslateTable[PADMINUS ] = KX_PADMINUS ; - m_reverseKeyTranslateTable[PADENTER ] = KX_PADENTER ; - m_reverseKeyTranslateTable[PADPLUSKEY ] = KX_PADPLUSKEY ; - - - m_reverseKeyTranslateTable[F1KEY ] = KX_F1KEY ; - m_reverseKeyTranslateTable[F2KEY ] = KX_F2KEY ; - m_reverseKeyTranslateTable[F3KEY ] = KX_F3KEY ; - m_reverseKeyTranslateTable[F4KEY ] = KX_F4KEY ; - m_reverseKeyTranslateTable[F5KEY ] = KX_F5KEY ; - m_reverseKeyTranslateTable[F6KEY ] = KX_F6KEY ; - m_reverseKeyTranslateTable[F7KEY ] = KX_F7KEY ; - m_reverseKeyTranslateTable[F8KEY ] = KX_F8KEY ; - m_reverseKeyTranslateTable[F9KEY ] = KX_F9KEY ; - m_reverseKeyTranslateTable[F10KEY ] = KX_F10KEY ; - m_reverseKeyTranslateTable[F11KEY ] = KX_F11KEY ; - m_reverseKeyTranslateTable[F12KEY ] = KX_F12KEY ; - m_reverseKeyTranslateTable[F13KEY ] = KX_F13KEY ; - m_reverseKeyTranslateTable[F14KEY ] = KX_F14KEY ; - m_reverseKeyTranslateTable[F15KEY ] = KX_F15KEY ; - m_reverseKeyTranslateTable[F16KEY ] = KX_F16KEY ; - m_reverseKeyTranslateTable[F17KEY ] = KX_F17KEY ; - m_reverseKeyTranslateTable[F18KEY ] = KX_F18KEY ; - m_reverseKeyTranslateTable[F19KEY ] = KX_F19KEY ; - - m_reverseKeyTranslateTable[PAUSEKEY ] = KX_PAUSEKEY ; - m_reverseKeyTranslateTable[INSERTKEY ] = KX_INSERTKEY ; - m_reverseKeyTranslateTable[HOMEKEY ] = KX_HOMEKEY ; - m_reverseKeyTranslateTable[PAGEUPKEY ] = KX_PAGEUPKEY ; - m_reverseKeyTranslateTable[PAGEDOWNKEY ] = KX_PAGEDOWNKEY ; - m_reverseKeyTranslateTable[ENDKEY ] = KX_ENDKEY ; + m_reverseKeyTranslateTable[ZEROKEY ] = KX_ZEROKEY; + m_reverseKeyTranslateTable[ONEKEY ] = KX_ONEKEY; + m_reverseKeyTranslateTable[TWOKEY ] = KX_TWOKEY; + m_reverseKeyTranslateTable[THREEKEY ] = KX_THREEKEY; + m_reverseKeyTranslateTable[FOURKEY ] = KX_FOURKEY; + m_reverseKeyTranslateTable[FIVEKEY ] = KX_FIVEKEY; + m_reverseKeyTranslateTable[SIXKEY ] = KX_SIXKEY; + m_reverseKeyTranslateTable[SEVENKEY ] = KX_SEVENKEY; + m_reverseKeyTranslateTable[EIGHTKEY ] = KX_EIGHTKEY; + m_reverseKeyTranslateTable[NINEKEY ] = KX_NINEKEY; - - } + m_reverseKeyTranslateTable[CAPSLOCKKEY ] = KX_CAPSLOCKKEY; + + m_reverseKeyTranslateTable[LEFTCTRLKEY ] = KX_LEFTCTRLKEY; + m_reverseKeyTranslateTable[LEFTALTKEY ] = KX_LEFTALTKEY; + m_reverseKeyTranslateTable[RIGHTALTKEY ] = KX_RIGHTALTKEY; + m_reverseKeyTranslateTable[RIGHTCTRLKEY ] = KX_RIGHTCTRLKEY; + m_reverseKeyTranslateTable[RIGHTSHIFTKEY ] = KX_RIGHTSHIFTKEY; + m_reverseKeyTranslateTable[LEFTSHIFTKEY ] = KX_LEFTSHIFTKEY; + + m_reverseKeyTranslateTable[ESCKEY ] = KX_ESCKEY; + m_reverseKeyTranslateTable[TABKEY ] = KX_TABKEY; + m_reverseKeyTranslateTable[RETKEY ] = KX_RETKEY; + m_reverseKeyTranslateTable[SPACEKEY ] = KX_SPACEKEY; + m_reverseKeyTranslateTable[LINEFEEDKEY ] = KX_LINEFEEDKEY; + m_reverseKeyTranslateTable[BACKSPACEKEY ] = KX_BACKSPACEKEY; + m_reverseKeyTranslateTable[DELKEY ] = KX_DELKEY; + m_reverseKeyTranslateTable[SEMICOLONKEY ] = KX_SEMICOLONKEY; + m_reverseKeyTranslateTable[PERIODKEY ] = KX_PERIODKEY; + m_reverseKeyTranslateTable[COMMAKEY ] = KX_COMMAKEY; + m_reverseKeyTranslateTable[QUOTEKEY ] = KX_QUOTEKEY; + m_reverseKeyTranslateTable[ACCENTGRAVEKEY ] = KX_ACCENTGRAVEKEY; + m_reverseKeyTranslateTable[MINUSKEY ] = KX_MINUSKEY; + m_reverseKeyTranslateTable[SLASHKEY ] = KX_SLASHKEY; + m_reverseKeyTranslateTable[BACKSLASHKEY ] = KX_BACKSLASHKEY; + m_reverseKeyTranslateTable[EQUALKEY ] = KX_EQUALKEY; + m_reverseKeyTranslateTable[LEFTBRACKETKEY ] = KX_LEFTBRACKETKEY; + m_reverseKeyTranslateTable[RIGHTBRACKETKEY ] = KX_RIGHTBRACKETKEY; + + m_reverseKeyTranslateTable[LEFTARROWKEY ] = KX_LEFTARROWKEY; + m_reverseKeyTranslateTable[DOWNARROWKEY ] = KX_DOWNARROWKEY; + m_reverseKeyTranslateTable[RIGHTARROWKEY ] = KX_RIGHTARROWKEY; + m_reverseKeyTranslateTable[UPARROWKEY ] = KX_UPARROWKEY; + + m_reverseKeyTranslateTable[PAD2 ] = KX_PAD2; + m_reverseKeyTranslateTable[PAD4 ] = KX_PAD4; + m_reverseKeyTranslateTable[PAD6 ] = KX_PAD6; + m_reverseKeyTranslateTable[PAD8 ] = KX_PAD8; + + m_reverseKeyTranslateTable[PAD1 ] = KX_PAD1; + m_reverseKeyTranslateTable[PAD3 ] = KX_PAD3; + m_reverseKeyTranslateTable[PAD5 ] = KX_PAD5; + m_reverseKeyTranslateTable[PAD7 ] = KX_PAD7; + m_reverseKeyTranslateTable[PAD9 ] = KX_PAD9; + + m_reverseKeyTranslateTable[PADPERIOD ] = KX_PADPERIOD; + m_reverseKeyTranslateTable[PADSLASHKEY ] = KX_PADSLASHKEY; + m_reverseKeyTranslateTable[PADASTERKEY ] = KX_PADASTERKEY; + + + m_reverseKeyTranslateTable[PAD0 ] = KX_PAD0; + m_reverseKeyTranslateTable[PADMINUS ] = KX_PADMINUS; + m_reverseKeyTranslateTable[PADENTER ] = KX_PADENTER; + m_reverseKeyTranslateTable[PADPLUSKEY ] = KX_PADPLUSKEY; + + + m_reverseKeyTranslateTable[F1KEY ] = KX_F1KEY; + m_reverseKeyTranslateTable[F2KEY ] = KX_F2KEY; + m_reverseKeyTranslateTable[F3KEY ] = KX_F3KEY; + m_reverseKeyTranslateTable[F4KEY ] = KX_F4KEY; + m_reverseKeyTranslateTable[F5KEY ] = KX_F5KEY; + m_reverseKeyTranslateTable[F6KEY ] = KX_F6KEY; + m_reverseKeyTranslateTable[F7KEY ] = KX_F7KEY; + m_reverseKeyTranslateTable[F8KEY ] = KX_F8KEY; + m_reverseKeyTranslateTable[F9KEY ] = KX_F9KEY; + m_reverseKeyTranslateTable[F10KEY ] = KX_F10KEY; + m_reverseKeyTranslateTable[F11KEY ] = KX_F11KEY; + m_reverseKeyTranslateTable[F12KEY ] = KX_F12KEY; + m_reverseKeyTranslateTable[F13KEY ] = KX_F13KEY; + m_reverseKeyTranslateTable[F14KEY ] = KX_F14KEY; + m_reverseKeyTranslateTable[F15KEY ] = KX_F15KEY; + m_reverseKeyTranslateTable[F16KEY ] = KX_F16KEY; + m_reverseKeyTranslateTable[F17KEY ] = KX_F17KEY; + m_reverseKeyTranslateTable[F18KEY ] = KX_F18KEY; + m_reverseKeyTranslateTable[F19KEY ] = KX_F19KEY; + + m_reverseKeyTranslateTable[PAUSEKEY ] = KX_PAUSEKEY; + m_reverseKeyTranslateTable[INSERTKEY ] = KX_INSERTKEY; + m_reverseKeyTranslateTable[HOMEKEY ] = KX_HOMEKEY; + m_reverseKeyTranslateTable[PAGEUPKEY ] = KX_PAGEUPKEY; + m_reverseKeyTranslateTable[PAGEDOWNKEY ] = KX_PAGEDOWNKEY; + m_reverseKeyTranslateTable[ENDKEY ] = KX_ENDKEY; + } virtual ~BL_BlenderInputDevice() - { + { - } - - KX_EnumInputs ToNative(unsigned short incode) { + } + + KX_EnumInputs ToNative(unsigned short incode) { return m_reverseKeyTranslateTable[incode]; } virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)=0; -// virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0; + // virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0; virtual bool ConvertBlenderEvent(unsigned short incode,short val)=0; - + #ifdef WITH_CXX_GUARDEDALLOC public: void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_BlenderInputDevice"); } void operator delete(void *mem) { MEM_freeN(mem); } #endif -}; +}; #endif //__KX_BLENDERINPUTDEVICE diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 50afac6992e..063544932de 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -129,6 +129,50 @@ void BL_ActionActuator::SetBlendTime (float newtime){ m_blendframe = newtime; } +void BL_ActionActuator::SetLocalTime(float curtime) +{ + float dt = (curtime-m_starttime)*KX_KetsjiEngine::GetAnimFrameRate(); + + if (m_endframe < m_startframe) + dt = -dt; + + m_localtime = m_startframe + dt; + + // Handle wrap around + if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) + { + switch(m_playtype) + { + case ACT_ACTION_PLAY: + // Clamp + m_localtime = m_endframe; + break; + case ACT_ACTION_LOOP_END: + // Put the time back to the beginning + m_localtime = m_startframe; + m_starttime = curtime; + break; + case ACT_ACTION_PINGPONG: + // Swap the start and end frames + float temp = m_startframe; + m_startframe = m_endframe; + m_endframe = temp; + + m_starttime = curtime; + + break; + } + } +} + +void BL_ActionActuator::ResetStartTime(float curtime) +{ + float dt = m_localtime - m_startframe; + + m_starttime = curtime - dt / (KX_KetsjiEngine::GetAnimFrameRate()); + //SetLocalTime(curtime); +} + CValue* BL_ActionActuator::GetReplica() { BL_ActionActuator* replica = new BL_ActionActuator(*this);//m_float,GetName()); replica->ProcessReplica(); @@ -173,6 +217,9 @@ bool BL_ActionActuator::Update(double curtime, bool frame) case ACT_ACTION_FROM_PROP: CValue* prop = GetParent()->GetProperty(m_propname); + // If we don't have a property, we can't do anything, so just bail + if (!prop) return false; + playtype = BL_Action::ACT_MODE_PLAY; start = end = prop->GetNumber(); @@ -194,11 +241,46 @@ bool BL_ActionActuator::Update(double curtime, bool frame) RemoveAllEvents(); } + if (m_flag & ACT_FLAG_ATTEMPT_PLAY) + SetLocalTime(curtime); + if (bUseContinue && (m_flag & ACT_FLAG_ACTIVE)) - m_localtime = obj->GetActionFrame(m_layer); - - if (bPositiveEvent) { + m_localtime = obj->GetActionFrame(m_layer); + ResetStartTime(curtime); + } + + // Handle a frame property if it's defined + if ((m_flag & ACT_FLAG_ACTIVE) && m_framepropname[0] != 0) + { + CValue* oldprop = obj->GetProperty(m_framepropname); + CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer)); + if (oldprop) + oldprop->SetValue(newval); + else + obj->SetProperty(m_framepropname, newval); + + newval->Release(); + } + + // Handle a finished animation + if ((m_flag & ACT_FLAG_PLAY_END) && obj->IsActionDone(m_layer)) + { + m_flag &= ~ACT_FLAG_ACTIVE; + m_flag &= ~ACT_FLAG_ATTEMPT_PLAY; + obj->StopAction(m_layer); + return false; + } + + // If a different action is playing, we've been overruled and are no longer active + if (obj->GetCurrentAction(m_layer) != m_action) + m_flag &= ~ACT_FLAG_ACTIVE; + + if (bPositiveEvent || (m_flag & ACT_FLAG_ATTEMPT_PLAY && !(m_flag & ACT_FLAG_ACTIVE))) + { + if (bPositiveEvent) + ResetStartTime(curtime); + if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, playtype, m_layer_weight, m_ipo_flags)) { m_flag |= ACT_FLAG_ACTIVE; @@ -210,11 +292,11 @@ bool BL_ActionActuator::Update(double curtime, bool frame) else m_flag &= ~ACT_FLAG_PLAY_END; } - else - return false; + m_flag |= ACT_FLAG_ATTEMPT_PLAY; } else if ((m_flag & ACT_FLAG_ACTIVE) && bNegativeEvent) { + m_flag &= ~ACT_FLAG_ATTEMPT_PLAY; bAction *curr_action = obj->GetCurrentAction(m_layer); if (curr_action && curr_action != m_action) { @@ -259,27 +341,6 @@ bool BL_ActionActuator::Update(double curtime, bool frame) } } - // Handle a frame property if it's defined - if ((m_flag & ACT_FLAG_ACTIVE) && m_framepropname[0] != 0) - { - CValue* oldprop = obj->GetProperty(m_framepropname); - CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer)); - if (oldprop) - oldprop->SetValue(newval); - else - obj->SetProperty(m_framepropname, newval); - - newval->Release(); - } - - // Handle a finished animation - if ((m_flag & ACT_FLAG_PLAY_END) && obj->IsActionDone(m_layer)) - { - m_flag &= ~ACT_FLAG_ACTIVE; - obj->StopAction(m_layer); - return false; - } - return true; } diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 5324cb10885..357c2b4a05e 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -64,6 +64,8 @@ public: virtual void ProcessReplica(); void SetBlendTime (float newtime); + void SetLocalTime (float curtime); + void ResetStartTime (float curtime); bAction* GetAction() { return m_action; } void SetAction(bAction* act) { m_action= act; } @@ -150,7 +152,7 @@ enum { ACT_FLAG_ACTIVE = 1<<3, ACT_FLAG_CONTINUE = 1<<4, ACT_FLAG_PLAY_END = 1<<5, - + ACT_FLAG_ATTEMPT_PLAY = 1<<6, }; #endif diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 4daed538b39..fcfc07e631e 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1483,7 +1483,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, { objprop.m_gamesoftFlag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT; - objprop.m_soft_linStiff = 0.5;; + objprop.m_soft_linStiff = 0.5; objprop.m_soft_angStiff = 1.f; /* angular stiffness 0..1 */ objprop.m_soft_volume= 1.f; /* volume preservation 0..1 */ @@ -1911,11 +1911,11 @@ void RBJconstraints(Object *ob)//not used KX_IPhysicsController* getPhId(CListValue* sumolist,STR_String busc){//not used - for (int j=0;jGetCount();j++) + for (int j=0;jGetCount();j++) { - KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j); - if (gameobje->GetName()==busc) - return gameobje->GetPhysicsController(); + KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j); + if (gameobje->GetName()==busc) + return gameobje->GetPhysicsController(); } return 0; @@ -1924,11 +1924,11 @@ KX_IPhysicsController* getPhId(CListValue* sumolist,STR_String busc){//not used KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist){ - for (int j=0;jGetCount();j++) + for (int j=0;jGetCount();j++) { - KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j); - if (gameobje->GetName()==busc) - return gameobje; + KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j); + if (gameobje->GetName()==busc) + return gameobje; } return 0; @@ -2629,7 +2629,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData(); //we need to pass a full constraint frame, not just axis - + //localConstraintFrameBasis MT_Matrix3x3 localCFrame(MT_Vector3(dat->axX,dat->axY,dat->axZ)); MT_Vector3 axis0 = localCFrame.getColumn(0); diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index 90466e930fb..0968478ce7e 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -88,7 +88,7 @@ protected: // -- int m_tvtot; BL_DeformableGameObject* m_gameobj; - double m_lastDeformUpdate; + double m_lastDeformUpdate; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index befe0f6e784..f4c683f60ba 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -69,12 +69,12 @@ extern "C"{ //#undef __NLA_DEFNORMALS BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj, - Object *bmeshobj, - RAS_MeshObject *mesh) - : - BL_SkinDeformer(gameobj,bmeshobj, mesh), - m_useShapeDrivers(false), - m_lastShapeUpdate(-1) + Object *bmeshobj, + RAS_MeshObject *mesh) + : + BL_SkinDeformer(gameobj,bmeshobj, mesh), + m_useShapeDrivers(false), + m_lastShapeUpdate(-1) { m_key = m_bmesh->key; m_bmesh->key = copy_key(m_key); diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index 655cc9d7aeb..609603ae52b 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -46,8 +46,8 @@ class BL_ShapeDeformer : public BL_SkinDeformer { public: BL_ShapeDeformer(BL_DeformableGameObject *gameobj, - Object *bmeshobj, - RAS_MeshObject *mesh); + Object *bmeshobj, + RAS_MeshObject *mesh); /* this second constructor is needed for making a mesh deformable on the fly. */ BL_ShapeDeformer(BL_DeformableGameObject *gameobj, diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp index 8fc01032de7..f003a0049e5 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.cpp +++ b/source/gameengine/Converter/BlenderWorldInfo.cpp @@ -170,10 +170,10 @@ float BlenderWorldInfo::getMistStart() float BlenderWorldInfo::getMistDistance() { return m_mistdistance; -} - +} + + - float BlenderWorldInfo::getMistColorRed() { return m_mistcolor[0]; diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index ffb9a8ce691..7191730187c 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -679,7 +679,7 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo) MEM_freeN( tmpicu ); localDel_ipoCurve( tmpicu ); } - } + } } else { ipo = NULL; // XXX add_ipo(blenderObject->id.name+2, ID_OB); blenderObject->ipo = ipo; diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 9621d05b5cc..8fc224fba6f 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -942,7 +942,7 @@ void BL_ConvertActuators(char* maggiename, case ACT_2DFILTER: { bTwoDFilterActuator *_2dfilter = (bTwoDFilterActuator*) bact->data; - SCA_2DFilterActuator *tmp = NULL; + SCA_2DFilterActuator *tmp = NULL; RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode; switch(_2dfilter->type) @@ -996,7 +996,7 @@ void BL_ConvertActuators(char* maggiename, filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER; break; } - + tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag, _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),scene); @@ -1012,8 +1012,8 @@ void BL_ConvertActuators(char* maggiename, } } - baseact = tmp; - + baseact = tmp; + } break; case ACT_PARENT: diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index ad6941dcdc7..a250bc6064b 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -276,7 +276,7 @@ void BL_ConvertSensors(struct Object* blenderobject, gReverseKeyTranslateTable[ENDKEY ] = SCA_IInputDevice::KX_ENDKEY; } - int executePriority = 0; + int executePriority = 0; int uniqueint = 0; int count = 0; bSensor* sens = (bSensor*)blenderobject->sensors.first; diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index 0ee99f5335b..b13dbe324f5 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -257,7 +257,7 @@ SG_Controller *BL_CreateCameraIPO(struct bAction *action, KX_GameObject* camera ipocontr->m_clipstart = blendercamera->clipsta; ipocontr->m_clipend = blendercamera->clipend; - BL_InterpolatorList *adtList= GetAdtList(blendercamera->adt->action, converter); + BL_InterpolatorList *adtList= GetAdtList(action, converter); // For each active channel in the adtList add an // interpolator to the game object. diff --git a/source/gameengine/Expressions/InputParser.cpp b/source/gameengine/Expressions/InputParser.cpp index 7957c82e7f9..27f4f0b10cb 100644 --- a/source/gameengine/Expressions/InputParser.cpp +++ b/source/gameengine/Expressions/InputParser.cpp @@ -192,89 +192,89 @@ void CParser::NextSym() switch(ch) { - case '(': - sym = lbracksym; NextCh(); - break; - case ')': - sym = rbracksym; NextCh(); - break; - case ',': - sym = commasym; NextCh(); - break; - case '%' : - sym = opsym; opkind = OPmodulus; NextCh(); - break; - case '+' : - sym = opsym; opkind = OPplus; NextCh(); - break; - case '-' : - sym = opsym; opkind = OPminus; NextCh(); - break; - case '*' : - sym = opsym; opkind = OPtimes; NextCh(); - break; - case '/' : - sym = opsym; opkind = OPdivide; NextCh(); - break; - case '&' : - sym = opsym; opkind = OPand; NextCh(); TermChar('&'); - break; - case '|' : - sym = opsym; opkind = OPor; NextCh(); TermChar('|'); - break; - case '=' : - sym = opsym; opkind = OPequal; NextCh(); TermChar('='); - break; - case '!' : - sym = opsym; - NextCh(); - if (ch == '=') - { - opkind = OPunequal; + case '(': + sym = lbracksym; NextCh(); + break; + case ')': + sym = rbracksym; NextCh(); + break; + case ',': + sym = commasym; NextCh(); + break; + case '%' : + sym = opsym; opkind = OPmodulus; NextCh(); + break; + case '+' : + sym = opsym; opkind = OPplus; NextCh(); + break; + case '-' : + sym = opsym; opkind = OPminus; NextCh(); + break; + case '*' : + sym = opsym; opkind = OPtimes; NextCh(); + break; + case '/' : + sym = opsym; opkind = OPdivide; NextCh(); + break; + case '&' : + sym = opsym; opkind = OPand; NextCh(); TermChar('&'); + break; + case '|' : + sym = opsym; opkind = OPor; NextCh(); TermChar('|'); + break; + case '=' : + sym = opsym; opkind = OPequal; NextCh(); TermChar('='); + break; + case '!' : + sym = opsym; NextCh(); - } - else - { - opkind = OPnot; - } - break; - case '>': - sym = opsym; - NextCh(); - if (ch == '=') - { - opkind = OPgreaterequal; + if (ch == '=') + { + opkind = OPunequal; + NextCh(); + } + else + { + opkind = OPnot; + } + break; + case '>': + sym = opsym; NextCh(); - } - else - { - opkind = OPgreater; - } - break; - case '<': - sym = opsym; - NextCh(); - if (ch == '=') { - opkind = OPlessequal; + if (ch == '=') + { + opkind = OPgreaterequal; + NextCh(); + } + else + { + opkind = OPgreater; + } + break; + case '<': + sym = opsym; NextCh(); - } else { - opkind = OPless; - } - break; - case '\"' : { - int start; - sym = constsym; - constkind = stringtype; - NextCh(); - start = chcount; - while ((ch != '\"') && (ch != 0x0)) + if (ch == '=') { + opkind = OPlessequal; + NextCh(); + } else { + opkind = OPless; + } + break; + case '\"' : { + int start; + sym = constsym; + constkind = stringtype; NextCh(); - GrabRealString(start); - TermChar('\"'); // check for eol before '\"' - break; - } - case 0x0: sym = eolsym; break; - default: + start = chcount; + while ((ch != '\"') && (ch != 0x0)) + NextCh(); + GrabRealString(start); + TermChar('\"'); // check for eol before '\"' + break; + } + case 0x0: sym = eolsym; break; + default: { int start; start = chcount; @@ -301,7 +301,7 @@ void CParser::NextSym() } GrabString(start); } else if (((ch >= 'a') && (ch <= 'z')) - || ((ch >= 'A') && (ch <= 'Z'))) + || ((ch >= 'A') && (ch <= 'Z'))) { // reserved word? start = chcount; @@ -358,18 +358,18 @@ STR_String CParser::Symbol2Str(int s) { // returns a string representation of of symbol s, // for use in Term when generating an error switch(s) { - case errorsym: return "error"; - case lbracksym: return "("; - case rbracksym: return ")"; - case commasym: return ","; - case opsym: return "operator"; - case constsym: return "constant"; - case sumsym: return "SUM"; - case ifsym: return "IF"; - case whocodedsym: return "WHOMADE"; - case eolsym: return "end of line"; - case idsym: return "identifier"; - default: return "unknown"; // should not happen + case errorsym: return "error"; + case lbracksym: return "("; + case rbracksym: return ")"; + case commasym: return ","; + case opsym: return "operator"; + case constsym: return "constant"; + case sumsym: return "SUM"; + case ifsym: return "IF"; + case whocodedsym: return "WHOMADE"; + case eolsym: return "end of line"; + case idsym: return "identifier"; + default: return "unknown"; // should not happen } } @@ -391,19 +391,19 @@ int CParser::Priority(int optorkind) { // returns the priority of an operator // higher number means higher priority switch(optorkind) { - case OPor: return 1; - case OPand: return 2; - case OPgreater: - case OPless: - case OPgreaterequal: - case OPlessequal: - case OPequal: - case OPunequal: return 3; - case OPplus: - case OPminus: return 4; - case OPmodulus: - case OPtimes: - case OPdivide: return 5; + case OPor: return 1; + case OPand: return 2; + case OPgreater: + case OPless: + case OPgreaterequal: + case OPlessequal: + case OPequal: + case OPunequal: return 3; + case OPplus: + case OPminus: return 4; + case OPmodulus: + case OPtimes: + case OPdivide: return 5; } MT_assert(false); return 0; // should not happen diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index c270d9a312b..7c1824cd4eb 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -40,20 +40,20 @@ SCA_2DFilterActuator::~SCA_2DFilterActuator() } SCA_2DFilterActuator::SCA_2DFilterActuator( - SCA_IObject *gameobj, + SCA_IObject *gameobj, RAS_2DFilterManager::RAS_2DFILTER_MODE type, - short flag, - float float_arg, - int int_arg, - RAS_IRasterizer* rasterizer, - SCA_IScene* scene) + short flag, + float float_arg, + int int_arg, + RAS_IRasterizer* rasterizer, + SCA_IScene* scene) : SCA_IActuator(gameobj, KX_ACT_2DFILTER), - m_type(type), - m_disableMotionBlur(flag), - m_float_arg(float_arg), - m_int_arg(int_arg), - m_rasterizer(rasterizer), - m_scene(scene) + m_type(type), + m_disableMotionBlur(flag), + m_float_arg(float_arg), + m_int_arg(int_arg), + m_rasterizer(rasterizer), + m_scene(scene) { m_gameobj = NULL; if(gameobj){ @@ -65,9 +65,9 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( CValue* SCA_2DFilterActuator::GetReplica() { - SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this); - replica->ProcessReplica(); - return replica; + SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this); + replica->ProcessReplica(); + return replica; } @@ -94,7 +94,7 @@ bool SCA_2DFilterActuator::Update() m_scene->Update2DFilter(m_propNames, m_gameobj, m_type, m_int_arg, m_shaderText); } // once the filter is in place, no need to update it again => disable the actuator - return false; + return false; } diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h index 7f31c1713f4..82c82ac3be5 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -52,19 +52,19 @@ private: public: - SCA_2DFilterActuator( - class SCA_IObject* gameobj, - RAS_2DFilterManager::RAS_2DFILTER_MODE type, - short flag, - float float_arg, - int int_arg, - RAS_IRasterizer* rasterizer, - SCA_IScene* scene); + SCA_2DFilterActuator( + class SCA_IObject* gameobj, + RAS_2DFilterManager::RAS_2DFILTER_MODE type, + short flag, + float float_arg, + int int_arg, + RAS_IRasterizer* rasterizer, + SCA_IScene* scene); void SetShaderText(const char *text); - virtual ~SCA_2DFilterActuator(); - virtual bool Update(); + virtual ~SCA_2DFilterActuator(); + virtual bool Update(); - virtual CValue* GetReplica(); + virtual CValue* GetReplica(); }; #endif diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 0d09e33a81b..85982bd3c0f 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -216,8 +216,8 @@ void SCA_ISensor::UnregisterToManager() void SCA_ISensor::ActivateControllers(class SCA_LogicManager* logicmgr) { - for(vector::const_iterator c= m_linkedcontrollers.begin(); - c!=m_linkedcontrollers.end();++c) + for(vector::const_iterator c= m_linkedcontrollers.begin(); + c!=m_linkedcontrollers.end();++c) { SCA_IController* contr = *c; if (contr->IsActive()) diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 741448b1096..f90f1e19a67 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -105,7 +105,7 @@ public: }; SCA_ISensor(SCA_IObject* gameobj, - class SCA_EventManager* eventmgr);; + class SCA_EventManager* eventmgr); ~SCA_ISensor(); virtual void ReParent(SCA_IObject* parent); diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index 513be43ec28..a2374ccb9da 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -132,7 +132,7 @@ bool SCA_KeyboardSensor::Evaluate() // cerr << "SCA_KeyboardSensor::Eval event, sensing for "<< m_hotkey << " at device " << inputdev << "\n"; /* See if we need to do logging: togPropState exists and is - * different from 0 */ + * different from 0 */ CValue* myparent = GetParent(); CValue* togPropState = myparent->GetProperty(m_toggleprop); if (togPropState && @@ -400,7 +400,7 @@ void SCA_KeyboardSensor::LogKeystrokes(void) int index = 0; /* Check on all keys whether they were pushed. This does not - * untangle the ordering, so don't type too fast :) */ + * untangle the ordering, so don't type too fast :) */ for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++) { const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i); diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index a1836163e9c..93d2ae2c1c5 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -50,12 +50,12 @@ /* ------------------------------------------------------------------------- */ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr, - int startx,int starty, - short int mousemode, - SCA_IObject* gameobj) + int startx,int starty, + short int mousemode, + SCA_IObject* gameobj) : SCA_ISensor(gameobj,eventmgr), - m_x(startx), - m_y(starty) + m_x(startx), + m_y(starty) { m_mousemode = mousemode; m_triggermode = true; @@ -72,7 +72,7 @@ void SCA_MouseSensor::Init() SCA_MouseSensor::~SCA_MouseSensor() { - /* Nothing to be done here. */ + /* Nothing to be done here. */ } void SCA_MouseSensor::UpdateHotkey(void *self) diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index 3ccbfea7ed5..739e566237b 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -34,7 +34,7 @@ #ifndef KX_PYTHONCONTROLLER_H #define KX_PYTHONCONTROLLER_H - + #include "SCA_IController.h" #include "SCA_LogicManager.h" #include "BoolValue.h" diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index d76f3f775a5..c9d11a27c76 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -207,10 +207,10 @@ bool SCA_RandomActuator::Update() sensible values. The termination condition states two things: 1. s >= 0 is not allowed: to prevent the distro from - getting a bias towards high values. This is a small + getting a bias towards high values. This is a small correction, really, and might also be left out. 2. s == 0 is not allowed: to prevent a division by zero - when renormalising the drawn value to the desired + when renormalising the drawn value to the desired distribution shape. As a side effect, the distro will never yield the exact mean. I am not sure whether this is consistent, since the error diff --git a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp index 06c24c8211b..67af6237a8d 100644 --- a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp @@ -68,12 +68,12 @@ SCA_RandomNumberGenerator::~SCA_RandomNumberGenerator() { void SCA_RandomNumberGenerator::SetStartVector(void) { /* setting initial seeds to mt[N] using */ - /* the generator Line 25 of Table 1 in */ - /* [KNUTH 1981, The Art of Computer Programming */ - /* Vol. 2 (2nd Ed.), pp102] */ - mt[0] = m_seed & 0xffffffff; - for (mti = 1; mti < N; mti++) - mt[mti] = (69069 * mt[mti-1]) & 0xffffffff; + /* the generator Line 25 of Table 1 in */ + /* [KNUTH 1981, The Art of Computer Programming */ + /* Vol. 2 (2nd Ed.), pp102] */ + mt[0] = m_seed & 0xffffffff; + for (mti = 1; mti < N; mti++) + mt[mti] = (69069 * mt[mti-1]) & 0xffffffff; } long SCA_RandomNumberGenerator::GetSeed() { return m_seed; } @@ -87,39 +87,39 @@ void SCA_RandomNumberGenerator::SetSeed(long newseed) * This is the important part: copied verbatim :) */ unsigned long SCA_RandomNumberGenerator::Draw() { - static unsigned long mag01[2] = { 0x0, MATRIX_A }; - /* mag01[x] = x * MATRIX_A for x=0,1 */ + static unsigned long mag01[2] = { 0x0, MATRIX_A }; + /* mag01[x] = x * MATRIX_A for x=0,1 */ - unsigned long y; + unsigned long y; - if (mti >= N) { /* generate N words at one time */ - int kk; + if (mti >= N) { /* generate N words at one time */ + int kk; - /* I set this in the constructor, so it is always satisfied ! */ -// if (mti == N+1) /* if sgenrand() has not been called, */ -// GEN_srand(4357); /* a default initial seed is used */ - - for (kk = 0; kk < N - M; kk++) { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1]; + /* I set this in the constructor, so it is always satisfied ! */ + // if (mti == N+1) /* if sgenrand() has not been called, */ + // GEN_srand(4357); /* a default initial seed is used */ - mti = 0; - } - - y = mt[mti++]; - y ^= TEMPERING_SHIFT_U(y); - y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B; - y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C; - y ^= TEMPERING_SHIFT_L(y); + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); + mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1]; + } + for (; kk < N-1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); + mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1]; + } + y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1]; - return y; + mti = 0; + } + + y = mt[mti++]; + y ^= TEMPERING_SHIFT_U(y); + y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B; + y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C; + y ^= TEMPERING_SHIFT_L(y); + + return y; } float SCA_RandomNumberGenerator::DrawFloat() { diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index 99e25042582..c23722d2d3c 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -48,8 +48,8 @@ /* ------------------------------------------------------------------------- */ SCA_RandomSensor::SCA_RandomSensor(SCA_EventManager* eventmgr, - SCA_IObject* gameobj, - int startseed) + SCA_IObject* gameobj, + int startseed) : SCA_ISensor(gameobj,eventmgr) { m_basegenerator = new SCA_RandomNumberGenerator(startseed); @@ -65,10 +65,10 @@ SCA_RandomSensor::~SCA_RandomSensor() void SCA_RandomSensor::Init() { - m_iteration = 0; + m_iteration = 0; m_interval = 0; m_lastdraw = false; - m_currentDraw = m_basegenerator->Draw(); + m_currentDraw = m_basegenerator->Draw(); } @@ -97,19 +97,19 @@ bool SCA_RandomSensor::IsPositiveTrigger() bool SCA_RandomSensor::Evaluate() { - /* Random generator is the generator from Line 25 of Table 1 in */ - /* [KNUTH 1981, The Art of Computer Programming Vol. 2 */ - /* (2nd Ed.), pp102] */ - /* It's a very simple max. length sequence generator. We can */ - /* draw 32 bool values before having to generate the next */ - /* sequence value. There are some theorems that will tell you */ - /* this is a reasonable way of generating bools. Check Knuth. */ - /* Furthermore, we only draw each -eth frame. */ + /* Random generator is the generator from Line 25 of Table 1 in */ + /* [KNUTH 1981, The Art of Computer Programming Vol. 2 */ + /* (2nd Ed.), pp102] */ + /* It's a very simple max. length sequence generator. We can */ + /* draw 32 bool values before having to generate the next */ + /* sequence value. There are some theorems that will tell you */ + /* this is a reasonable way of generating bools. Check Knuth. */ + /* Furthermore, we only draw each -eth frame. */ bool evaluateResult = false; if (++m_interval > m_pulse_frequency) { - bool drawResult = false; + bool drawResult = false; m_interval = 0; if (m_iteration > 31) { m_currentDraw = m_basegenerator->Draw(); @@ -122,8 +122,8 @@ bool SCA_RandomSensor::Evaluate() evaluateResult = drawResult != m_lastdraw; m_lastdraw = drawResult; } - - /* now pass this result to some controller */ + + /* now pass this result to some controller */ return evaluateResult; } diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp index f5eefd5cc08..4a03062b6ad 100644 --- a/source/gameengine/GameLogic/SCA_XORController.cpp +++ b/source/gameengine/GameLogic/SCA_XORController.cpp @@ -63,22 +63,22 @@ void SCA_XORController::Trigger(SCA_LogicManager* logicmgr) bool sensorresult = false; for (vector::const_iterator is=m_linkedsensors.begin(); - !(is==m_linkedsensors.end());is++) + !(is==m_linkedsensors.end());is++) { SCA_ISensor* sensor = *is; if (sensor->GetState()) { if (sensorresult == true) { - sensorresult = false; + sensorresult = false; break; } - sensorresult = true; + sensorresult = true; } } for (vector::const_iterator i=m_linkedactuators.begin(); - !(i==m_linkedactuators.end());i++) + !(i==m_linkedactuators.end());i++) { SCA_IActuator* actua = *i; logicmgr->AddActiveActuator(actua,sensorresult); diff --git a/source/gameengine/GamePlayer/common/bmfont.cpp b/source/gameengine/GamePlayer/common/bmfont.cpp index e3b900173d9..ecb2c4f3bd1 100644 --- a/source/gameengine/GamePlayer/common/bmfont.cpp +++ b/source/gameengine/GamePlayer/common/bmfont.cpp @@ -190,7 +190,7 @@ void detectBitmapFont(ImBuf *ibuf) long i; if (ibuf != NULL) { - // bitmap must have an x size that is a power of two + // bitmap must have an x size that is a power of two if (is_power_of_two(ibuf->x)) { rect = (unsigned char *) (ibuf->rect + (ibuf->x * (ibuf->y - 1))); // printf ("starts with: %s %c %c %c %c\n", rect, rect[0], rect[1], rect[2], rect[3]); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 546ec69bf29..5bc6093a9ff 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -139,7 +139,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system) GPG_Application::~GPG_Application(void) { - if(m_pyGlobalDictString) { + if(m_pyGlobalDictString) { delete [] m_pyGlobalDictString; m_pyGlobalDictString = 0; m_pyGlobalDictString_Length = 0; @@ -192,7 +192,7 @@ static LRESULT CALLBACK screenSaverWindowProc(HWND hwnd, UINT uMsg, WPARAM wPara LONG dx = scr_save_mouse_pos.x - pt.x; LONG dy = scr_save_mouse_pos.y - pt.y; if (abs(dx) > SCR_SAVE_MOUSE_MOVE_THRESHOLD - || abs(dy) > SCR_SAVE_MOUSE_MOVE_THRESHOLD) + || abs(dy) > SCR_SAVE_MOUSE_MOVE_THRESHOLD) { close = TRUE; } diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index cbbeb9419d1..3f8bcf9e2ad 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -380,12 +380,12 @@ int main(int argc, char** argv) #endif /* __linux__ */ BLI_where_am_i(bprogname, sizeof(bprogname), argv[0]); #ifdef __APPLE__ - // Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh) - /* - IBNibRef nibRef; - WindowRef window; - OSStatus err; - + // Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh) + /* + IBNibRef nibRef; + WindowRef window; + OSStatus err; + // Create a Nib reference passing the name of the nib file (without the .nib extension) // CreateNibReference only searches into the application bundle. err = ::CreateNibReference(CFSTR("main"), &nibRef); @@ -398,7 +398,7 @@ int main(int argc, char** argv) // We don't need the nib reference anymore. ::DisposeNibReference(nibRef); - */ + */ #endif // __APPLE__ // We don't use threads directly in the BGE, but we need to call this so things like @@ -421,7 +421,7 @@ int main(int argc, char** argv) BLF_init(11, U.dpi); BLF_lang_init(); BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size); - + // Parse command line options #if defined(DEBUG) printf("argv[0] = '%s'\n", argv[0]); diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index 91982a424c7..4ae937cdcd6 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -63,7 +63,7 @@ int BL_BlenderShader::GetAttribNum() GPU_material_vertex_attributes(mGPUMat, &attribs); - for(i = 0; i < attribs.totlayer; i++) + for(i = 0; i < attribs.totlayer; i++) if(attribs.layer[i].glindex+1 > enabled) enabled= attribs.layer[i].glindex+1; diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp index e8e65371d3a..72f1cee8855 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp @@ -66,8 +66,8 @@ void KX_NetworkEventManager::NextFrame() for (it.begin();!it.end();++it) { // printf("KX_NetworkEventManager::proceed sensor %.2f\n", curtime); - // process queue - (*it)->Activate(m_logicmgr); + // process queue + (*it)->Activate(m_logicmgr); } // now a list of triggerer sensors has been built diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h index ff9131f464e..405e2d52989 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h @@ -43,7 +43,7 @@ class KX_NetworkEventManager : public SCA_EventManager public: KX_NetworkEventManager(class SCA_LogicManager* logicmgr, - class NG_NetworkDeviceInterface *ndi); + class NG_NetworkDeviceInterface *ndi); virtual ~KX_NetworkEventManager (); virtual void NextFrame(); @@ -51,7 +51,7 @@ public: SCA_LogicManager* GetLogicManager() { return m_logicmgr; } class NG_NetworkDeviceInterface* GetNetworkDevice() { - return m_ndi; } + return m_ndi; } }; #endif //KX_NETWORK_EVENTMANAGER_H diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp index 2e0abc0290c..9fd09506c0d 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp @@ -91,8 +91,7 @@ bool KX_NetworkMessageActuator::Update() CValue* KX_NetworkMessageActuator::GetReplica() { - KX_NetworkMessageActuator* replica = - new KX_NetworkMessageActuator(*this); + KX_NetworkMessageActuator* replica = new KX_NetworkMessageActuator(*this); replica->ProcessReplica(); return replica; diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 6dcf50fa18f..a795a4eddc6 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -50,11 +50,11 @@ #endif KX_NetworkMessageSensor::KX_NetworkMessageSensor( - class KX_NetworkEventManager* eventmgr, // our eventmanager - class NG_NetworkScene *NetworkScene, // our scene - SCA_IObject* gameobj, // the sensor controlling object - const STR_String &subject -) : + class KX_NetworkEventManager* eventmgr, // our eventmanager + class NG_NetworkScene *NetworkScene, // our scene + SCA_IObject* gameobj, // the sensor controlling object + const STR_String &subject + ) : SCA_ISensor(gameobj,eventmgr), m_NetworkScene(NetworkScene), m_subject(subject), @@ -67,7 +67,7 @@ KX_NetworkMessageSensor::KX_NetworkMessageSensor( void KX_NetworkMessageSensor::Init() { - m_IsUp = false; + m_IsUp = false; } KX_NetworkMessageSensor::~KX_NetworkMessageSensor() diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 4226896aec0..33da17cc505 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -56,21 +56,21 @@ KX_BlenderMaterial::KX_BlenderMaterial() } void KX_BlenderMaterial::Initialize( - KX_Scene *scene, - BL_Material *data) + KX_Scene *scene, + BL_Material *data) { RAS_IPolyMaterial::Initialize( - data->texname[0], - data->matname, - data->materialindex, - data->tile, - data->tilexrep[0], - data->tileyrep[0], - data->mode, - data->transp, - ((data->ras_mode &ALPHA)!=0), - ((data->ras_mode &ZSORT)!=0) - ); + data->texname[0], + data->matname, + data->materialindex, + data->tile, + data->tilexrep[0], + data->tileyrep[0], + data->mode, + data->transp, + ((data->ras_mode &ALPHA)!=0), + ((data->ras_mode &ZSORT)!=0) + ); mMaterial = data; mShader = 0; mBlenderShader = 0; @@ -80,7 +80,7 @@ void KX_BlenderMaterial::Initialize( mConstructed = false; mPass = 0; // -------------------------------- - // RAS_IPolyMaterial variables... + // RAS_IPolyMaterial variables... m_flag |= RAS_BLENDERMAT; m_flag |= (mMaterial->IdMode>=ONETEX)? RAS_MULTITEX: 0; m_flag |= ((mMaterial->ras_mode & USE_LIGHT)!=0)? RAS_MULTILIGHT: 0; @@ -93,14 +93,11 @@ void KX_BlenderMaterial::Initialize( mMaterial->num_enabled = enabled>=max?max:enabled; // test the sum of the various modes for equality - // so we can ether accept or reject this material - // as being equal, this is rather important to + // so we can ether accept or reject this material + // as being equal, this is rather important to // prevent material bleeding for(int i=0; inum_enabled; i++) { - m_multimode += - ( mMaterial->flag[i] + - mMaterial->blend_mode[i] - ); + m_multimode += (mMaterial->flag[i] + mMaterial->blend_mode[i]); } m_multimode += mMaterial->IdMode+ (mMaterial->ras_mode & ~(COLLIDER|USE_LIGHT)); } diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index fde01961fd5..6e5513991f9 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -213,16 +213,16 @@ MT_Scalar KX_BulletPhysicsController::GetMass() MT_Vector3 KX_BulletPhysicsController::GetLocalInertia() { - MT_Vector3 inertia(0.f, 0.f, 0.f); - btVector3 inv_inertia; - if (GetRigidBody()) { - inv_inertia = GetRigidBody()->getInvInertiaDiagLocal(); - if (!btFuzzyZero(inv_inertia.getX()) && - !btFuzzyZero(inv_inertia.getY()) && - !btFuzzyZero(inv_inertia.getZ())) + MT_Vector3 inertia(0.f, 0.f, 0.f); + btVector3 inv_inertia; + if (GetRigidBody()) { + inv_inertia = GetRigidBody()->getInvInertiaDiagLocal(); + if (!btFuzzyZero(inv_inertia.getX()) && + !btFuzzyZero(inv_inertia.getY()) && + !btFuzzyZero(inv_inertia.getZ())) inertia = MT_Vector3(1.f/inv_inertia.getX(), 1.f/inv_inertia.getY(), 1.f/inv_inertia.getZ()); - } - return inertia; + } + return inertia; } MT_Vector3 KX_BulletPhysicsController::getReactionForce() diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index c60c931c33b..a488d646792 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -271,18 +271,18 @@ void KX_Camera::ExtractFrustumSphere() if (m_set_frustum_center) return; - // compute sphere for the general case and not only symmetric frustum: - // the mirror code in ImageRender can use very asymmetric frustum. - // We will put the sphere center on the line that goes from origin to the center of the far clipping plane - // This is the optimal position if the frustum is symmetric or very asymmetric and probably close - // to optimal for the general case. The sphere center position is computed so that the distance to - // the near and far extreme frustum points are equal. + // compute sphere for the general case and not only symmetric frustum: + // the mirror code in ImageRender can use very asymmetric frustum. + // We will put the sphere center on the line that goes from origin to the center of the far clipping plane + // This is the optimal position if the frustum is symmetric or very asymmetric and probably close + // to optimal for the general case. The sphere center position is computed so that the distance to + // the near and far extreme frustum points are equal. - // get the transformation matrix from device coordinate to camera coordinate + // get the transformation matrix from device coordinate to camera coordinate MT_Matrix4x4 clip_camcs_matrix = m_projection_matrix; clip_camcs_matrix.invert(); - if (m_projection_matrix[3][3] == MT_Scalar(0.0)) + if (m_projection_matrix[3][3] == MT_Scalar(0.0)) { // frustrum projection // detect which of the corner of the far clipping plane is the farthest to the origin @@ -302,7 +302,7 @@ void KX_Camera::ExtractFrustumSphere() MT_Scalar len; for (int i=0; i<4; i++) { - hpoint = clip_camcs_matrix*npoint; + hpoint = clip_camcs_matrix*npoint; point.setValue(hpoint[0]/hpoint[3], hpoint[1]/hpoint[3], hpoint[2]/hpoint[3]); len = point.dot(point); if (len > F) @@ -321,7 +321,7 @@ void KX_Camera::ExtractFrustumSphere() farcenter *= 0.25; // the extreme near point is the opposite point on the near clipping plane nfar.setValue(-nfar[0], -nfar[1], -1., 1.); - nfar = clip_camcs_matrix*nfar; + nfar = clip_camcs_matrix*nfar; nearpoint.setValue(nfar[0]/nfar[3], nfar[1]/nfar[3], nfar[2]/nfar[3]); // this is a frustrum projection N = nearpoint.dot(nearpoint); @@ -340,7 +340,7 @@ void KX_Camera::ExtractFrustumSphere() z = (F-N)/(2.0*(e-s+c*(f-n))); m_frustum_center = MT_Point3(farcenter[0]*z/e, farcenter[1]*z/e, z); m_frustum_radius = m_frustum_center.distance(farpoint); - } + } else { // orthographic projection diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 2e1fb933ad0..00c5e5803a8 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -42,34 +42,34 @@ Developed as part of a Research and Development project for SAT - La Société d // constructor KX_Dome::KX_Dome ( - RAS_ICanvas* canvas, - /// rasterizer - RAS_IRasterizer* rasterizer, - /// render tools - RAS_IRenderTools* rendertools, - /// engine - KX_KetsjiEngine* engine, + RAS_ICanvas* canvas, + /// rasterizer + RAS_IRasterizer* rasterizer, + /// render tools + RAS_IRenderTools* rendertools, + /// engine + KX_KetsjiEngine* engine, - short res, //resolution of the mesh - short mode, //mode - fisheye, truncated, warped, panoramic, ... - short angle, - float resbuf, //size adjustment of the buffer - short tilt, - struct Text* warptext + short res, //resolution of the mesh + short mode, //mode - fisheye, truncated, warped, panoramic, ... + short angle, + float resbuf, //size adjustment of the buffer + short tilt, + struct Text* warptext -): - dlistSupported(false), - canvaswidth(-1), canvasheight(-1), - m_drawingmode(engine->GetDrawType()), - m_resolution(res), - m_mode(mode), - m_angle(angle), - m_resbuffer(resbuf), - m_tilt(tilt), - m_canvas(canvas), - m_rasterizer(rasterizer), - m_rendertools(rendertools), - m_engine(engine) + ): + dlistSupported(false), + canvaswidth(-1), canvasheight(-1), + m_drawingmode(engine->GetDrawType()), + m_resolution(res), + m_mode(mode), + m_angle(angle), + m_resbuffer(resbuf), + m_tilt(tilt), + m_canvas(canvas), + m_rasterizer(rasterizer), + m_rendertools(rendertools), + m_engine(engine) { warp.usemesh = false; fboSupported = false; @@ -1984,9 +1984,9 @@ void KX_Dome::DrawDomeWarped(void) int can_width = m_viewport.GetRight(); int can_height = m_viewport.GetTop(); - double screen_ratio = can_width/ (double) can_height; + double screen_ratio = can_width/ (double) can_height; - glOrtho(-screen_ratio,screen_ratio,-1.0,1.0,-20.0,10.0); + glOrtho(-screen_ratio,screen_ratio,-1.0,1.0,-20.0,10.0); glMatrixMode(GL_TEXTURE); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index d51e2aa5386..6adaea2d6ad 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -87,32 +87,32 @@ typedef unsigned long uint_ptr; static MT_Point3 dummy_point= MT_Point3(0.0, 0.0, 0.0); static MT_Vector3 dummy_scaling = MT_Vector3(1.0, 1.0, 1.0); -static MT_Matrix3x3 dummy_orientation = MT_Matrix3x3( 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0); +static MT_Matrix3x3 dummy_orientation = MT_Matrix3x3(1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0); KX_GameObject::KX_GameObject( - void* sgReplicationInfo, - SG_Callbacks callbacks) - : SCA_IObject(), - m_bDyna(false), - m_layer(0), - m_pBlenderObject(NULL), - m_pBlenderGroupObject(NULL), - m_bSuspendDynamics(false), - m_bUseObjectColor(false), - m_bIsNegativeScaling(false), - m_bVisible(true), - m_bCulled(true), - m_bOccluder(false), - m_pPhysicsController1(NULL), - m_pGraphicController(NULL), - m_xray(false), - m_pHitObject(NULL), - m_actionManager(NULL), - m_isDeformable(false) + void* sgReplicationInfo, + SG_Callbacks callbacks) + : SCA_IObject(), + m_bDyna(false), + m_layer(0), + m_pBlenderObject(NULL), + m_pBlenderGroupObject(NULL), + m_bSuspendDynamics(false), + m_bUseObjectColor(false), + m_bIsNegativeScaling(false), + m_bVisible(true), + m_bCulled(true), + m_bOccluder(false), + m_pPhysicsController1(NULL), + m_pGraphicController(NULL), + m_xray(false), + m_pHitObject(NULL), + m_actionManager(NULL), + m_isDeformable(false) #ifdef WITH_PYTHON - , m_attr_dict(NULL) + , m_attr_dict(NULL) #endif { m_ignore_activity_culling = false; @@ -159,6 +159,7 @@ KX_GameObject::~KX_GameObject() } if (m_actionManager) { + KX_GetActiveScene()->RemoveAnimatedObject(this); delete m_actionManager; } #ifdef WITH_PYTHON @@ -355,8 +356,8 @@ BL_ActionManager* KX_GameObject::GetActionManager() { // We only want to create an action manager if we need it if (!m_actionManager) - m_actionManager = new BL_ActionManager(this); - + { KX_GetActiveScene()->AddAnimatedObject(this); m_actionManager = new BL_ActionManager(this); + } return m_actionManager; } @@ -3124,7 +3125,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getActionFrame, layer_check(layer, "getActionFrame"); - return PyLong_FromLong(GetActionFrame(layer)); + return PyFloat_FromDouble(GetActionFrame(layer)); } KX_PYMETHODDEF_DOC(KX_GameObject, setActionFrame, diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index b1a214b7c1c..ca67333166c 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -116,7 +116,7 @@ bool KX_KetsjiEngine::m_restrict_anim_fps = false; * Constructor of the Ketsji Engine */ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) - : m_canvas(NULL), + : m_canvas(NULL), m_rasterizer(NULL), m_kxsystem(system), m_rendertools(NULL), @@ -886,8 +886,6 @@ void KX_KetsjiEngine::Render() { if((*it)->GetViewport()) { - // Change the active camera so Python scripts can figure out what viewport they're in - scene->SetActiveCamera(*it); if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); @@ -899,10 +897,6 @@ void KX_KetsjiEngine::Render() it++; } - - // Now change the camera back - scene->SetActiveCamera(cam); - PostRenderScene(scene); } @@ -1322,10 +1316,6 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) if (scene->GetPhysicsEnvironment()) scene->GetPhysicsEnvironment()->debugDrawWorld(); - -#ifdef WITH_PYTHON - scene->RunDrawingCallbacks(scene->GetPostDrawCB()); -#endif } void KX_KetsjiEngine::RenderFonts(KX_Scene* scene) @@ -1345,8 +1335,14 @@ To run once per scene */ void KX_KetsjiEngine::PostRenderScene(KX_Scene* scene) { + // We need to first make sure our viewport is correct (enabling multiple viewports can mess this up) + m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight()); + m_rendertools->MotionBlur(m_rasterizer); scene->Render2DFilters(m_canvas); +#ifdef WITH_PYTHON + scene->RunDrawingCallbacks(scene->GetPostDrawCB()); +#endif m_rasterizer->FlushDebugLines(); } diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 3f09eee013e..2f2c45cd5cc 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -355,11 +355,11 @@ PyObject* KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUT } else if (!strcmp(type, "NORMAL")) { retvalue = PyLong_FromSsize_t(RAS_LightObject::LIGHT_NORMAL); } - else { - /* should never happen */ - PyErr_SetString(PyExc_TypeError, "light.type: internal error, invalid light type"); - retvalue = NULL; - } + else { + /* should never happen */ + PyErr_SetString(PyExc_TypeError, "light.type: internal error, invalid light type"); + retvalue = NULL; + } return retvalue; } diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index ba41dc355f7..9ad09f9793b 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -119,7 +119,7 @@ CValue* KX_MeshProxy::GetReplica() { return NULL;} PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* args, PyObject* kwds) { - int matid= 1; + int matid= 1; STR_String matname; if (PyArg_ParseTuple(args,"i:getMaterialName",&matid)) @@ -131,13 +131,13 @@ PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* args, PyObject* kwds) } return PyUnicode_FromString(matname.Ptr()); - + } - + PyObject* KX_MeshProxy::PyGetTextureName(PyObject* args, PyObject* kwds) { - int matid= 1; + int matid= 1; STR_String matname; if (PyArg_ParseTuple(args,"i:getTextureName",&matid)) @@ -154,7 +154,7 @@ PyObject* KX_MeshProxy::PyGetTextureName(PyObject* args, PyObject* kwds) PyObject* KX_MeshProxy::PyGetVertexArrayLength(PyObject* args, PyObject* kwds) { - int matid= 0; + int matid= 0; int length = 0; @@ -177,7 +177,7 @@ PyObject* KX_MeshProxy::PyGetVertexArrayLength(PyObject* args, PyObject* kwds) PyObject* KX_MeshProxy::PyGetVertex(PyObject* args, PyObject* kwds) { - int vertexindex; + int vertexindex; int matindex; if (!PyArg_ParseTuple(args,"ii:getVertex",&matindex,&vertexindex)) @@ -195,7 +195,7 @@ PyObject* KX_MeshProxy::PyGetVertex(PyObject* args, PyObject* kwds) PyObject* KX_MeshProxy::PyGetPolygon(PyObject* args, PyObject* kwds) { - int polyindex= 1; + int polyindex= 1; PyObject* polyob = NULL; if (!PyArg_ParseTuple(args,"i:getPolygon",&polyindex)) diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 6cb80028858..34f5c26415d 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -121,14 +121,14 @@ bool KX_MouseFocusSensor::Evaluate() } } if (reset) { - // force an event + // force an event result = true; } } else { /* No focus behaviour required: revert to the basic mode. This - * mode is never used, because the converter never makes this - * sensor for a mouse-key event. It is here for - * completeness. */ + * mode is never used, because the converter never makes this + * sensor for a mouse-key event. It is here for + * completeness. */ result = SCA_MouseSensor::Evaluate(); m_positive_event = (m_val!=0); } diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 7289ffc6e29..cb59ef42699 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -237,9 +237,9 @@ bool KX_ObjectActuator::Update() if (m_current_linear_factor > 1.0) m_current_linear_factor = 1.0; linV = m_current_linear_factor * m_linear_velocity; - parent->setLinearVelocity(linV,(m_bitLocalFlag.LinearVelocity) != 0); + parent->setLinearVelocity(linV,(m_bitLocalFlag.LinearVelocity) != 0); } else { - parent->setLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0); + parent->setLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0); } } } @@ -260,7 +260,7 @@ bool KX_ObjectActuator::Update() if (m_current_angular_factor > 1.0) m_current_angular_factor = 1.0; angV = m_current_angular_factor * m_angular_velocity; - parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0); + parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0); } else { parent->setAngularVelocity(m_angular_velocity,(m_bitLocalFlag.AngularVelocity) != 0); } diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp index d9483083aa1..bd743159950 100644 --- a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp +++ b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp @@ -51,6 +51,6 @@ void KX_OrientationInterpolator::Execute(float currentTime) const { MT_Scalar ss = si*sh; m_target.setValue(cj*ch, sj*sc-cs, sj*cc+ss, - cj*sh, sj*ss+cc, sj*cs-sc, - -sj, cj*si, cj*ci); + cj*sh, sj*ss+cc, sj*cs-sc, + -sj, cj*si, cj*ci); } diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 9d0597051ad..d32f267f0e0 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -187,7 +187,7 @@ void KX_PolygonMaterial::DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& c rasty->SetCullFace(true); if ((m_drawingmode & RAS_IRasterizer::KX_LINES) || - (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) + (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) rasty->SetLines(true); else rasty->SetLines(false); diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 06db84feb23..395e2048cb7 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -389,10 +389,10 @@ static PyObject* gPyGetSpectrum(PyObject*) { PyObject* resultlist = PyList_New(512); - for (int index = 0; index < 512; index++) - { - PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(0.0)); - } + for (int index = 0; index < 512; index++) + { + PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(0.0)); + } return resultlist; } @@ -479,13 +479,13 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) char cpath[sizeof(gp_GamePythonPath)]; char *searchpath = NULL; PyObject* list, *value; - - DIR *dp; - struct dirent *dirp; - + + DIR *dp; + struct dirent *dirp; + if (!PyArg_ParseTuple(args, "|s:getBlendFileList", &searchpath)) return NULL; - + list = PyList_New(0); if (searchpath) { @@ -495,23 +495,23 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) /* Get the dir only */ BLI_split_dirfile(gp_GamePythonPath, cpath, NULL); } - - if((dp = opendir(cpath)) == NULL) { + + if((dp = opendir(cpath)) == NULL) { /* todo, show the errno, this shouldnt happen anyway if the blendfile is readable */ fprintf(stderr, "Could not read directoty (%s) failed, code %d (%s)\n", cpath, errno, strerror(errno)); return list; - } + } - while ((dirp = readdir(dp)) != NULL) { + while ((dirp = readdir(dp)) != NULL) { if (BLI_testextensie(dirp->d_name, ".blend")) { value= PyUnicode_DecodeFSDefault(dirp->d_name); PyList_Append(list, value); Py_DECREF(value); } - } + } - closedir(dp); - return list; + closedir(dp); + return list; } static char gPyAddScene_doc[] = @@ -1208,6 +1208,28 @@ static PyObject* gPyGetMaterialType(PyObject*) return PyLong_FromSsize_t(flag); } +static PyObject* gPySetAnisotropicFiltering(PyObject*, PyObject* args) +{ + short level; + + if (!PyArg_ParseTuple(args, "h:setAnisotropicFiltering", &level)) + return NULL; + + if (level != 1 && level != 2 && level != 4 && level != 8 && level != 16) { + PyErr_SetString(PyExc_ValueError, "Rasterizer.setAnisotropicFiltering(level): Expected value of 1, 2, 4, 8, or 16 for value"); + return NULL; + } + + gp_Rasterizer->SetAnisotropicFiltering(level); + + Py_RETURN_NONE; +} + +static PyObject* gPyGetAnisotropicFiltering(PyObject*, PyObject* args) +{ + return PyLong_FromLong(gp_Rasterizer->GetAnisotropicFiltering()); +} + static PyObject* gPyDrawLine(PyObject*, PyObject* args) { PyObject* ob_from; @@ -1272,6 +1294,10 @@ static struct PyMethodDef rasterizer_methods[] = { METH_VARARGS, "set the state of a GLSL material setting"}, {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting, METH_VARARGS, "get the state of a GLSL material setting"}, + {"setAnisotropicFiltering", (PyCFunction) gPySetAnisotropicFiltering, + METH_VARARGS, "set the anisotropic filtering level (must be one of 1, 2, 4, 8, 16)"}, + {"getAnisotropicFiltering", (PyCFunction) gPyGetAnisotropicFiltering, + METH_VARARGS, "get the anisotropic filtering level"}, {"drawLine", (PyCFunction) gPyDrawLine, METH_VARARGS, "draw a line on the screen"}, { NULL, (PyCFunction) NULL, 0, NULL } @@ -1636,9 +1662,9 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack // Check for errors if (PyErr_Occurred()) - { + { Py_FatalError("can't initialize module bge.logic"); - } + } return m; } @@ -1928,12 +1954,12 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) gp_Rasterizer = rasty; - PyObject* m; - PyObject* d; - PyObject* item; + PyObject* m; + PyObject* d; + PyObject* item; /* Use existing module where possible - * be careful not to init any runtime vars after this */ + * be careful not to init any runtime vars after this */ m = PyImport_ImportModule( "Rasterizer" ); if(m) { Py_DECREF(m); @@ -1941,32 +1967,32 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) } else { PyErr_Clear(); - + // Create the module and add the functions m = PyModule_Create(&Rasterizer_module_def); PyDict_SetItemString(PySys_GetObject("modules"), Rasterizer_module_def.m_name, m); } - // Add some symbolic constants to the module - d = PyModule_GetDict(m); - ErrorObject = PyUnicode_FromString("Rasterizer.error"); - PyDict_SetItemString(d, "error", ErrorObject); - Py_DECREF(ErrorObject); + // Add some symbolic constants to the module + d = PyModule_GetDict(m); + ErrorObject = PyUnicode_FromString("Rasterizer.error"); + PyDict_SetItemString(d, "error", ErrorObject); + Py_DECREF(ErrorObject); - /* needed for get/setMaterialType */ - KX_MACRO_addTypesToDict(d, KX_TEXFACE_MATERIAL, KX_TEXFACE_MATERIAL); - KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL); - KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL); + /* needed for get/setMaterialType */ + KX_MACRO_addTypesToDict(d, KX_TEXFACE_MATERIAL, KX_TEXFACE_MATERIAL); + KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL); + KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL); - // XXXX Add constants here + // XXXX Add constants here - // Check for errors - if (PyErr_Occurred()) - { - Py_FatalError("can't initialize module Rasterizer"); - } + // Check for errors + if (PyErr_Occurred()) + { + Py_FatalError("can't initialize module Rasterizer"); + } - return d; + return d; } @@ -2205,9 +2231,9 @@ PyObject* initGameKeys() // Check for errors if (PyErr_Occurred()) - { + { Py_FatalError("can't initialize module GameKeys"); - } + } return d; } diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index a683c9857aa..aecf2ab3598 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -83,7 +83,7 @@ void KX_RaySensor::Init() KX_RaySensor::~KX_RaySensor() { - /* Nothing to be done here. */ + /* Nothing to be done here. */ } @@ -279,7 +279,7 @@ bool KX_RaySensor::Evaluate() /* now pass this result to some controller */ - if (m_rayHit) + if (m_rayHit) { if (!m_bTriggered) { @@ -288,14 +288,14 @@ bool KX_RaySensor::Evaluate() m_bTriggered = true; } else - { + { // notify logicsystem that ray is STILL hitting ... result = false; - - } + + } } - else - { + else + { if (m_bTriggered) { m_bTriggered = false; @@ -306,9 +306,9 @@ bool KX_RaySensor::Evaluate() { result = false; } - - } - if (reset) + + } + if (reset) // force an event result = true; diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp index 076669e325a..c5f3fefd4d3 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp @@ -44,11 +44,11 @@ #include "SCA_IScene.h" KX_SCA_EndObjectActuator::KX_SCA_EndObjectActuator(SCA_IObject *gameobj, - SCA_IScene* scene): - SCA_IActuator(gameobj, KX_ACT_END_OBJECT), - m_scene(scene) + SCA_IScene* scene): + SCA_IActuator(gameobj, KX_ACT_END_OBJECT), + m_scene(scene) { - // intentionally empty + // intentionally empty } /* End of constructor */ diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index a49c1bf4b4c..06e343cedb2 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -168,6 +168,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, m_lightlist= new CListValue(); m_inactivelist = new CListValue(); m_euthanasyobjects = new CListValue(); + m_animatedlist = new CListValue(); m_logicmgr = new SCA_LogicManager(); @@ -253,6 +254,9 @@ KX_Scene::~KX_Scene() if (m_euthanasyobjects) m_euthanasyobjects->Release(); + if (m_animatedlist) + m_animatedlist->Release(); + if (m_logicmgr) delete m_logicmgr; @@ -1502,10 +1506,20 @@ void KX_Scene::LogicBeginFrame(double curtime) m_logicmgr->BeginFrame(curtime, 1.0/KX_KetsjiEngine::GetTicRate()); } +void KX_Scene::AddAnimatedObject(CValue* gameobj) +{ + m_animatedlist->Add(gameobj); +} + +void KX_Scene::RemoveAnimatedObject(CValue* gameobj) +{ + m_animatedlist->RemoveValue(gameobj); +} + void KX_Scene::UpdateAnimations(double curtime) { // Update any animations - for (int i=0; iGetCount(); ++i) + for (int i=0; iGetCount(); ++i) ((KX_GameObject*)GetObjectList()->GetValue(i))->UpdateActionManager(curtime); } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index da9cc12c76a..499861bce50 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -130,6 +130,7 @@ protected: CListValue* m_parentlist; // all 'root' parents CListValue* m_lightlist; CListValue* m_inactivelist; // all objects that are not in the active layer + CListValue* m_animatedlist; // all animated objects SG_QList m_sghead; // list of nodes that needs scenegraph update // the Dlist is not object that must be updated @@ -334,6 +335,10 @@ public: int NewRemoveObject(CValue* gameobj); void ReplaceMesh(CValue* gameobj, void* meshob, bool use_gfx, bool use_phys); + + void AddAnimatedObject(CValue* gameobj); + void RemoveAnimatedObject(CValue* gameobj); + /** * @section Logic stuff * Initiate an update of the logic system. diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index edcba969811..f13f152c5d5 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -54,16 +54,16 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj, - SCA_IObject *ob, - int time, - bool allow3D, - int trackflag, - int upflag) - : SCA_IActuator(gameobj, KX_ACT_TRACKTO) + SCA_IObject *ob, + int time, + bool allow3D, + int trackflag, + int upflag) + : SCA_IActuator(gameobj, KX_ACT_TRACKTO) { - m_time = time; - m_allow3D = allow3D; - m_object = ob; + m_time = time; + m_allow3D = allow3D; + m_object = ob; m_trackflag = trackflag; m_upflag = upflag; m_parentobj = 0; diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index c5e96bd7454..bbf0134a859 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -57,7 +57,7 @@ class KX_TrackToActuator : public SCA_IActuator public: KX_TrackToActuator(SCA_IObject* gameobj, SCA_IObject *ob, int time, - bool threedee,int trackflag,int upflag); + bool threedee,int trackflag,int upflag); virtual ~KX_TrackToActuator(); virtual CValue* GetReplica() { KX_TrackToActuator* replica = new KX_TrackToActuator(*this); diff --git a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h index 67d0e741507..cb7807a86a6 100644 --- a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h +++ b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h @@ -52,8 +52,8 @@ public: virtual void NextFrame(); bool Connect(char *address, unsigned int port, char *password, - unsigned int localport, unsigned int timeout) { - return true;} + unsigned int localport, unsigned int timeout) { + return true;} bool Disconnect(void) {return true;} virtual void SendNetworkMessage(class NG_NetworkMessage* msg); diff --git a/source/gameengine/Network/NG_NetworkDeviceInterface.h b/source/gameengine/Network/NG_NetworkDeviceInterface.h index 6df228680ec..857b4660327 100644 --- a/source/gameengine/Network/NG_NetworkDeviceInterface.h +++ b/source/gameengine/Network/NG_NetworkDeviceInterface.h @@ -64,7 +64,7 @@ public: bool IsOnline(void) { return m_online; } virtual bool Connect(char *address, unsigned int port, char *password, - unsigned int localport, unsigned int timeout)=0; + unsigned int localport, unsigned int timeout)=0; virtual bool Disconnect(void)=0; virtual void SendNetworkMessage(NG_NetworkMessage* msg)=0; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 08445654916..82acd64161f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -216,12 +216,12 @@ struct CcdConstructionInfo ///more advanced collision filtering should be done in btCollisionDispatcher::NeedsCollision enum CollisionFilterGroups { - DefaultFilter = 1, - StaticFilter = 2, - KinematicFilter = 4, - DebrisFilter = 8, - SensorFilter = 16, - AllFilter = DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorFilter, + DefaultFilter = 1, + StaticFilter = 2, + KinematicFilter = 4, + DebrisFilter = 8, + SensorFilter = 16, + AllFilter = DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorFilter, }; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 3f0c4cb95a1..39b2022a1f4 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1200,7 +1200,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac // Bullet returns the normal from "outside". // If the user requests the real normal, compute it now - if (filterCallback.m_faceNormal) + if (filterCallback.m_faceNormal) { if (shape->isSoftBody()) { @@ -2564,8 +2564,8 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl btPlaneSpace1( axisInA, axis1, axis2 ); frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(), - axisInA.y(), axis1.y(), axis2.y(), - axisInA.z(), axis1.z(), axis2.z() ); + axisInA.y(), axis1.y(), axis2.y(), + axisInA.z(), axis1.z(), axis2.z() ); frameInA.setOrigin( pivotInA ); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 18e1282b111..c34a00513bf 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -164,7 +164,7 @@ protected: virtual float getConstraintParam(int constraintId,int param); - virtual void removeConstraint(int constraintid); + virtual void removeConstraint(int constraintid); virtual float getAppliedImpulse(int constraintid); diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index ed18ff0329e..725d00aa5cd 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -306,8 +306,8 @@ void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance) if(depth){ glGenTextures(1, (GLuint*)&texname[1]); glBindTexture(GL_TEXTURE_2D, texname[1]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, texturewidth,textureheight, - 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, texturewidth,textureheight, + 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -433,6 +433,9 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, 0, 0, texturewidth,textureheight, 0); } + // reverting to texunit 0, without this we get bug [#28462] + glActiveTextureARB(GL_TEXTURE0); + glViewport(0,0, texturewidth, textureheight); glDisable(GL_DEPTH_TEST); diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h index e6254f72511..5657fda4f3c 100644 --- a/source/gameengine/Rasterizer/RAS_CameraData.h +++ b/source/gameengine/Rasterizer/RAS_CameraData.h @@ -49,19 +49,19 @@ struct RAS_CameraData float m_focallength; RAS_CameraData(float lens = 35.0, float scale = 6.0, float clipstart = 0.1, float clipend = 5000.0, bool perspective = true, - float focallength = 3.0, bool viewport = false, int viewportleft = 0, int viewportbottom = 0, - int viewportright = 0, int viewporttop = 0) : - m_lens(lens), - m_scale(scale), - m_clipstart(clipstart), - m_clipend(clipend), - m_perspective(perspective), - m_viewport(viewport), - m_viewportleft(viewportleft), - m_viewportbottom(viewportbottom), - m_viewportright(viewportright), - m_viewporttop(viewporttop), - m_focallength(focallength) + float focallength = 3.0, bool viewport = false, int viewportleft = 0, int viewportbottom = 0, + int viewportright = 0, int viewporttop = 0) : + m_lens(lens), + m_scale(scale), + m_clipstart(clipstart), + m_clipend(clipend), + m_perspective(perspective), + m_viewport(viewport), + m_viewportleft(viewportleft), + m_viewportbottom(viewportbottom), + m_viewportright(viewportright), + m_viewporttop(viewporttop), + m_focallength(focallength) { } }; diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 305e2bca756..c46ebf742a0 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -417,6 +417,9 @@ public: virtual void SetBlendingMode(int blendmode)=0; virtual void SetFrontFace(bool ccw)=0; + + virtual void SetAnisotropicFiltering(short level)=0; + virtual short GetAnisotropicFiltering()=0; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h index a277d9835d8..3a3ea57d67b 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h @@ -38,17 +38,17 @@ uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; + vec4 sample[9]; - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } - gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] + - (2.0*sample[3]) + sample[4] + (2.0*sample[5]) + - sample[6] + (2.0*sample[7]) + sample[8]) / 13.0; + gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] + + (2.0*sample[3]) + sample[4] + (2.0*sample[5]) + + sample[6] + (2.0*sample[7]) + sample[8]) / 13.0; } ); #endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h index 6aeff254f77..f486be47f9f 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h @@ -38,17 +38,17 @@ uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; - vec4 maxValue = vec4(0.0); + vec4 sample[9]; + vec4 maxValue = vec4(0.0); - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - maxValue = max(sample[i], maxValue); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + maxValue = max(sample[i], maxValue); + } - gl_FragColor = maxValue; + gl_FragColor = maxValue; } ); #endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h index 1e9dccaec87..a1755dc0eeb 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h @@ -33,22 +33,22 @@ #define __RAS_EROSION2DFILTER const char * ErosionFragmentShader=STRINGIFY( -uniform sampler2D bgl_RenderedTexture; -uniform vec2 bgl_TextureCoordinateOffset[9]; + uniform sampler2D bgl_RenderedTexture; + uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; - vec4 minValue = vec4(1.0); + vec4 sample[9]; + vec4 minValue = vec4(1.0); - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - minValue = min(sample[i], minValue); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + minValue = min(sample[i], minValue); + } - gl_FragColor = minValue; + gl_FragColor = minValue; } ); #endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h index c7cfa83a11f..45c94d358ba 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h @@ -38,18 +38,18 @@ uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; + vec4 sample[9]; - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } - gl_FragColor = (sample[4] * 8.0) - - (sample[0] + sample[1] + sample[2] + - sample[3] + sample[5] + - sample[6] + sample[7] + sample[8]); + gl_FragColor = (sample[4] * 8.0) - + (sample[0] + sample[1] + sample[2] + + sample[3] + sample[5] + + sample[6] + sample[7] + sample[8]); gl_FragColor = vec4(gl_FragColor.rgb, 1.0); } ); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h index ada53cd751d..8d08d9077cb 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h @@ -38,23 +38,23 @@ uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; + vec4 sample[9]; - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } - vec4 horizEdge = sample[2] + sample[5] + sample[8] - - (sample[0] + sample[3] + sample[6]); + vec4 horizEdge = sample[2] + sample[5] + sample[8] - + (sample[0] + sample[3] + sample[6]); - vec4 vertEdge = sample[0] + sample[1] + sample[2] - - (sample[6] + sample[7] + sample[8]); + vec4 vertEdge = sample[0] + sample[1] + sample[2] - + (sample[6] + sample[7] + sample[8]); - gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + - (vertEdge.rgb * vertEdge.rgb)); - gl_FragColor.a = 1.0; + gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + + (vertEdge.rgb * vertEdge.rgb)); + gl_FragColor.a = 1.0; } ); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h index 0d68bc09c70..a9c827fa9e1 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h @@ -38,18 +38,18 @@ uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; + vec4 sample[9]; - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } - gl_FragColor = (sample[4] * 9.0) - - (sample[0] + sample[1] + sample[2] + - sample[3] + sample[5] + - sample[6] + sample[7] + sample[8]); + gl_FragColor = (sample[4] * 9.0) - + (sample[0] + sample[1] + sample[2] + + sample[3] + sample[5] + + sample[6] + sample[7] + sample[8]); } ); #endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h index 0f80f0f22b4..350ce19fafd 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h @@ -38,23 +38,23 @@ uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; + vec4 sample[9]; - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } - vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] - - (sample[0] + (2.0*sample[3]) + sample[6]); + vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] - + (sample[0] + (2.0*sample[3]) + sample[6]); - vec4 vertEdge = sample[0] + (2.0*sample[1]) + sample[2] - - (sample[6] + (2.0*sample[7]) + sample[8]); + vec4 vertEdge = sample[0] + (2.0*sample[1]) + sample[2] - + (sample[6] + (2.0*sample[7]) + sample[8]); - gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + - (vertEdge.rgb * vertEdge.rgb)); - gl_FragColor.a = 1.0; + gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + + (vertEdge.rgb * vertEdge.rgb)); + gl_FragColor.a = 1.0; } ); #endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 23e0a50ed6f..50d034a5a5a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -99,12 +99,16 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas) hinterlace_mask[i] = (i&1)*0xFFFFFFFF; } hinterlace_mask[32] = 0; + + m_prevafvalue = GPU_get_anisotropic(); } RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer() { + // Restore the previous AF value + GPU_set_anisotropic(m_prevafvalue); } bool RAS_OpenGLRasterizer::Init() @@ -1204,3 +1208,12 @@ void RAS_OpenGLRasterizer::SetFrontFace(bool ccw) m_last_frontface = ccw; } +void RAS_OpenGLRasterizer::SetAnisotropicFiltering(short level) +{ + GPU_set_anisotropic((float)level); +} + +short RAS_OpenGLRasterizer::GetAnisotropicFiltering() +{ + return (short)GPU_get_anisotropic(); +} diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 54fab906049..61568df91eb 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -94,6 +94,8 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer bool m_setfocallength; int m_noOfScanlines; + short m_prevafvalue; + //motion blur int m_motionblur; float m_motionblurvalue; @@ -294,6 +296,9 @@ public: virtual void SetBlendingMode(int blendmode); virtual void SetFrontFace(bool ccw); + virtual void SetAnisotropicFiltering(short level); + virtual short GetAnisotropicFiltering(); + #ifdef WITH_CXX_GUARDEDALLOC public: diff --git a/source/gameengine/SceneGraph/SG_BBox.cpp b/source/gameengine/SceneGraph/SG_BBox.cpp index b5618ebbf03..01107557481 100644 --- a/source/gameengine/SceneGraph/SG_BBox.cpp +++ b/source/gameengine/SceneGraph/SG_BBox.cpp @@ -142,8 +142,8 @@ SG_BBox SG_BBox::transform(const MT_Transform &world) const bool SG_BBox::inside(const MT_Point3 &point) const { return point[0] >= m_min[0] && point[0] <= m_max[0] && - point[1] >= m_min[1] && point[1] <= m_max[1] && - point[2] >= m_min[2] && point[2] <= m_max[2]; + point[1] >= m_min[1] && point[1] <= m_max[1] && + point[2] >= m_min[2] && point[2] <= m_max[2]; } bool SG_BBox::inside(const SG_BBox& other) const diff --git a/source/gameengine/SceneGraph/SG_DList.h b/source/gameengine/SceneGraph/SG_DList.h index b82e51e0d2f..9e7e514b27a 100644 --- a/source/gameengine/SceneGraph/SG_DList.h +++ b/source/gameengine/SceneGraph/SG_DList.h @@ -134,88 +134,88 @@ public: } }; - SG_DList() - { - m_flink = m_blink = this; - } + SG_DList() + { + m_flink = m_blink = this; + } SG_DList(const SG_DList& other) { - m_flink = m_blink = this; + m_flink = m_blink = this; } - virtual ~SG_DList() - { + virtual ~SG_DList() + { Delink(); - } + } - inline bool Empty() // Check for empty queue - { - return ( m_flink == this ); - } - bool AddBack( SG_DList *item ) // Add to the back - { + inline bool Empty() // Check for empty queue + { + return ( m_flink == this ); + } + bool AddBack( SG_DList *item ) // Add to the back + { if (!item->Empty()) return false; - item->m_blink = m_blink; - item->m_flink = this; - m_blink->m_flink = item; - m_blink = item; + item->m_blink = m_blink; + item->m_flink = this; + m_blink->m_flink = item; + m_blink = item; return true; - } - bool AddFront( SG_DList *item ) // Add to the back - { + } + bool AddFront( SG_DList *item ) // Add to the back + { if (!item->Empty()) return false; - item->m_flink = m_flink; - item->m_blink = this; - m_flink->m_blink = item; - m_flink = item; + item->m_flink = m_flink; + item->m_blink = this; + m_flink->m_blink = item; + m_flink = item; return true; - } - SG_DList *Remove() // Remove from the front - { - if (Empty()) - { - return NULL; - } - SG_DList* item = m_flink; - m_flink = item->m_flink; - m_flink->m_blink = this; - item->m_flink = item->m_blink = item; - return item; - } - bool Delink() // Remove from the middle - { + } + SG_DList *Remove() // Remove from the front + { + if (Empty()) + { + return NULL; + } + SG_DList* item = m_flink; + m_flink = item->m_flink; + m_flink->m_blink = this; + item->m_flink = item->m_blink = item; + return item; + } + bool Delink() // Remove from the middle + { if (Empty()) return false; m_blink->m_flink = m_flink; m_flink->m_blink = m_blink; m_flink = m_blink = this; return true; - } - inline SG_DList *Peek() // Look at front without removing - { - return m_flink; - } - inline SG_DList *Back() // Look at front without removing - { - return m_blink; - } - inline SG_DList *Self() - { - return this; - } - inline const SG_DList *Peek() const // Look at front without removing - { - return (const SG_DList*)m_flink; - } - inline const SG_DList *Back() const // Look at front without removing - { - return (const SG_DList*)m_blink; - } - inline const SG_DList *Self() const - { - return this; - } + } + inline SG_DList *Peek() // Look at front without removing + { + return m_flink; + } + inline SG_DList *Back() // Look at front without removing + { + return m_blink; + } + inline SG_DList *Self() + { + return this; + } + inline const SG_DList *Peek() const // Look at front without removing + { + return (const SG_DList*)m_flink; + } + inline const SG_DList *Back() const // Look at front without removing + { + return (const SG_DList*)m_blink; + } + inline const SG_DList *Self() const + { + return this; + } #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h index c42935bc487..8c0159fe8d4 100644 --- a/source/gameengine/SceneGraph/SG_IObject.h +++ b/source/gameengine/SceneGraph/SG_IObject.h @@ -194,7 +194,7 @@ public: /** * Clear the array of pointers to controllers associated with * this node. This does not delete the controllers themselves! - * This should be used very carefully to avoid memory + * This should be used very carefully to avoid memory * leaks. */ diff --git a/source/gameengine/SceneGraph/SG_QList.h b/source/gameengine/SceneGraph/SG_QList.h index de79c35821e..eb404b1a5a5 100644 --- a/source/gameengine/SceneGraph/SG_QList.h +++ b/source/gameengine/SceneGraph/SG_QList.h @@ -91,73 +91,73 @@ public: }; SG_QList() : SG_DList() - { - m_fqlink = m_bqlink = this; - } + { + m_fqlink = m_bqlink = this; + } SG_QList(const SG_QList& other) : SG_DList() { - m_fqlink = m_bqlink = this; + m_fqlink = m_bqlink = this; } - virtual ~SG_QList() - { + virtual ~SG_QList() + { QDelink(); - } + } - inline bool QEmpty() // Check for empty queue - { - return ( m_fqlink == this ); - } - bool QAddBack( SG_QList *item ) // Add to the back - { + inline bool QEmpty() // Check for empty queue + { + return ( m_fqlink == this ); + } + bool QAddBack( SG_QList *item ) // Add to the back + { if (!item->QEmpty()) return false; - item->m_bqlink = m_bqlink; - item->m_fqlink = this; - m_bqlink->m_fqlink = item; - m_bqlink = item; + item->m_bqlink = m_bqlink; + item->m_fqlink = this; + m_bqlink->m_fqlink = item; + m_bqlink = item; return true; - } - bool QAddFront( SG_QList *item ) // Add to the back - { + } + bool QAddFront( SG_QList *item ) // Add to the back + { if (!item->Empty()) return false; - item->m_fqlink = m_fqlink; - item->m_bqlink = this; - m_fqlink->m_bqlink = item; - m_fqlink = item; + item->m_fqlink = m_fqlink; + item->m_bqlink = this; + m_fqlink->m_bqlink = item; + m_fqlink = item; return true; - } - SG_QList *QRemove() // Remove from the front - { - if (QEmpty()) - { - return NULL; - } - SG_QList* item = m_fqlink; - m_fqlink = item->m_fqlink; - m_fqlink->m_bqlink = this; - item->m_fqlink = item->m_bqlink = item; - return item; - } - bool QDelink() // Remove from the middle - { + } + SG_QList *QRemove() // Remove from the front + { + if (QEmpty()) + { + return NULL; + } + SG_QList* item = m_fqlink; + m_fqlink = item->m_fqlink; + m_fqlink->m_bqlink = this; + item->m_fqlink = item->m_bqlink = item; + return item; + } + bool QDelink() // Remove from the middle + { if (QEmpty()) return false; m_bqlink->m_fqlink = m_fqlink; m_fqlink->m_bqlink = m_bqlink; m_fqlink = m_bqlink = this; return true; - } - inline SG_QList *QPeek() // Look at front without removing - { - return m_fqlink; - } - inline SG_QList *QBack() // Look at front without removing - { - return m_bqlink; - } - - + } + inline SG_QList *QPeek() // Look at front without removing + { + return m_fqlink; + } + inline SG_QList *QBack() // Look at front without removing + { + return m_bqlink; + } + + #ifdef WITH_CXX_GUARDEDALLOC public: void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_QList"); } diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp index ca778d164c8..09fb7278bfa 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.cpp +++ b/source/gameengine/SceneGraph/SG_Spatial.cpp @@ -109,18 +109,17 @@ SetParentRelation( */ - bool + bool SG_Spatial:: UpdateSpatialData( - const SG_Spatial *parent, - double time, - bool& parentUpdated -){ - - bool bComputesWorldTransform = false; + const SG_Spatial *parent, + double time, + bool& parentUpdated + ){ + bool bComputesWorldTransform = false; // update spatial controllers - + SGControllerList::iterator cit = GetSGControllerList().begin(); SGControllerList::const_iterator c_end = GetSGControllerList().end(); @@ -131,7 +130,7 @@ UpdateSpatialData( } // If none of the objects updated our values then we ask the - // parent_relation object owned by this class to update + // parent_relation object owned by this class to update // our world coordinates. if (!bComputesWorldTransform) diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp index fc316f1c3f0..30a8af4b125 100644 --- a/source/gameengine/VideoTexture/Exception.cpp +++ b/source/gameengine/VideoTexture/Exception.cpp @@ -201,20 +201,20 @@ void Exception::copy (const Exception & xpt) void registerAllExceptions(void) { - errGenerDesc.registerDesc(); - errNFoundDesc.registerDesc(); - MaterialNotAvailDesc.registerDesc(); - ImageSizesNotMatchDesc.registerDesc(); - ImageHasExportsDesc.registerDesc(); + errGenerDesc.registerDesc(); + errNFoundDesc.registerDesc(); + MaterialNotAvailDesc.registerDesc(); + ImageSizesNotMatchDesc.registerDesc(); + ImageHasExportsDesc.registerDesc(); InvalidColorChannelDesc.registerDesc(); - SceneInvalidDesc.registerDesc(); - CameraInvalidDesc.registerDesc(); - ObserverInvalidDesc.registerDesc(); - MirrorInvalidDesc.registerDesc(); - MirrorSizeInvalidDesc.registerDesc(); - MirrorNormalInvalidDesc.registerDesc(); - MirrorHorizontalDesc.registerDesc(); - MirrorTooSmallDesc.registerDesc(); - SourceVideoEmptyDesc.registerDesc(); - SourceVideoCreationDesc.registerDesc(); + SceneInvalidDesc.registerDesc(); + CameraInvalidDesc.registerDesc(); + ObserverInvalidDesc.registerDesc(); + MirrorInvalidDesc.registerDesc(); + MirrorSizeInvalidDesc.registerDesc(); + MirrorNormalInvalidDesc.registerDesc(); + MirrorHorizontalDesc.registerDesc(); + MirrorTooSmallDesc.registerDesc(); + SourceVideoEmptyDesc.registerDesc(); + SourceVideoCreationDesc.registerDesc(); } diff --git a/source/gameengine/VideoTexture/Exception.h b/source/gameengine/VideoTexture/Exception.h index 16248186108..11e617cf4ce 100644 --- a/source/gameengine/VideoTexture/Exception.h +++ b/source/gameengine/VideoTexture/Exception.h @@ -122,11 +122,11 @@ public: desc = m_description; } - void registerDesc(void) - { - if (std::find(m_expDescs.begin(), m_expDescs.end(), this) == m_expDescs.end()) - m_expDescs.push_back(this); - } + void registerDesc(void) + { + if (std::find(m_expDescs.begin(), m_expDescs.end(), this) == m_expDescs.end()) + m_expDescs.push_back(this); + } // list of exception descriptions static std::vector m_expDescs; diff --git a/source/gameengine/VideoTexture/FilterColor.h b/source/gameengine/VideoTexture/FilterColor.h index 2478727a6be..d0536ed2801 100644 --- a/source/gameengine/VideoTexture/FilterColor.h +++ b/source/gameengine/VideoTexture/FilterColor.h @@ -141,7 +141,7 @@ protected: /// calculate one color component unsigned int calcColor (unsigned int val, short idx) { - unsigned int col = VT_C(val,idx);; + unsigned int col = VT_C(val,idx); if (col <= levels[idx][0]) col = 0; else if (col >= levels[idx][1]) col = 0xFF; else col = (((col - levels[idx][0]) << 8) / levels[idx][2]) & 0xFF; diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp index a70c56a070c..65509ab9424 100644 --- a/source/gameengine/VideoTexture/ImageBase.cpp +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -375,7 +375,7 @@ void Image_dealloc (PyImage * self) if (self->m_image->m_exports > 0) { PyErr_SetString(PyExc_SystemError, - "deallocated Image object has exported buffers"); + "deallocated Image object has exported buffers"); PyErr_Print(); } // if release requires deleting of object, do it @@ -645,7 +645,7 @@ PyObject * Image_valid(PyImage * self, void * closure) int Image_getbuffer(PyImage *self, Py_buffer *view, int flags) { unsigned int * image; - int ret; + int ret; try { @@ -667,25 +667,25 @@ int Image_getbuffer(PyImage *self, Py_buffer *view, int flags) //return -1; goto error; } - if (view == NULL) + if (view == NULL) { - self->m_image->m_exports++; - return 0; - } - ret = PyBuffer_FillInfo(view, (PyObject*)self, image, self->m_image->getBuffSize(), 0, flags); - if (ret >= 0) - self->m_image->m_exports++; - return ret; + self->m_image->m_exports++; + return 0; + } + ret = PyBuffer_FillInfo(view, (PyObject*)self, image, self->m_image->getBuffSize(), 0, flags); + if (ret >= 0) + self->m_image->m_exports++; + return ret; error: // Return a empty buffer to avoid a crash in Python 3.1 // The bug is fixed in Python SVN 77916, as soon as the python revision used by Blender is // updated, you can simply return -1 and set the error static char* buf = (char *)""; - ret = PyBuffer_FillInfo(view, (PyObject*)self, buf, 0, 0, flags); - if (ret >= 0) - self->m_image->m_exports++; - return ret; + ret = PyBuffer_FillInfo(view, (PyObject*)self, buf, 0, 0, flags); + if (ret >= 0) + self->m_image->m_exports++; + return ret; } diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp index 7a8226aab03..aeef5d1694f 100644 --- a/source/gameengine/VideoTexture/ImageMix.cpp +++ b/source/gameengine/VideoTexture/ImageMix.cpp @@ -135,7 +135,7 @@ PyObject * setWeight (PyImage * self, PyObject * args) if (!getImageMix(self)->setWeight(id, weight)) { // if not set, report error - PyErr_SetString(PyExc_RuntimeError, "Invalid id of source");; + PyErr_SetString(PyExc_RuntimeError, "Invalid id of source"); return NULL; } // return none diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 6038416ba68..f7546d876b2 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -65,29 +65,29 @@ ImageRender::ImageRender (KX_Scene * scene, KX_Camera * camera) : m_owncamera(false), m_observer(NULL), m_mirror(NULL), - m_clip(100.f) + m_clip(100.f) { // initialize background color setBackground(0, 0, 255, 255); - // retrieve rendering objects - m_engine = KX_GetActiveEngine(); - m_rasterizer = m_engine->GetRasterizer(); - m_canvas = m_engine->GetCanvas(); - m_rendertools = m_engine->GetRenderTools(); + // retrieve rendering objects + m_engine = KX_GetActiveEngine(); + m_rasterizer = m_engine->GetRasterizer(); + m_canvas = m_engine->GetCanvas(); + m_rendertools = m_engine->GetRenderTools(); } // destructor ImageRender::~ImageRender (void) { - if (m_owncamera) - m_camera->Release(); + if (m_owncamera) + m_camera->Release(); } // set background color void ImageRender::setBackground (int red, int green, int blue, int alpha) { - m_background[0] = (red < 0) ? 0.f : (red > 255) ? 1.f : float(red)/255.f; + m_background[0] = (red < 0) ? 0.f : (red > 255) ? 1.f : float(red)/255.f; m_background[1] = (green < 0) ? 0.f : (green > 255) ? 1.f : float(green)/255.f; m_background[2] = (blue < 0) ? 0.f : (blue > 255) ? 1.f : float(blue)/255.f; m_background[3] = (alpha < 0) ? 0.f : (alpha > 255) ? 1.f : float(alpha)/255.f; @@ -97,157 +97,157 @@ void ImageRender::setBackground (int red, int green, int blue, int alpha) // capture image from viewport void ImageRender::calcImage (unsigned int texId, double ts) { - if (m_rasterizer->GetDrawingMode() != RAS_IRasterizer::KX_TEXTURED || // no need for texture - m_camera->GetViewport() || // camera must be inactive - m_camera == m_scene->GetActiveCamera()) - { - // no need to compute texture in non texture rendering - m_avail = false; - return; - } - // render the scene from the camera - Render(); + if (m_rasterizer->GetDrawingMode() != RAS_IRasterizer::KX_TEXTURED || // no need for texture + m_camera->GetViewport() || // camera must be inactive + m_camera == m_scene->GetActiveCamera()) + { + // no need to compute texture in non texture rendering + m_avail = false; + return; + } + // render the scene from the camera + Render(); // get image from viewport ImageViewport::calcImage(texId, ts); - // restore OpenGL state - m_canvas->EndFrame(); + // restore OpenGL state + m_canvas->EndFrame(); } void ImageRender::Render() { RAS_FrameFrustum frustrum; - if (!m_render) - return; + if (!m_render) + return; - if (m_mirror) - { - // mirror mode, compute camera frustrum, position and orientation - // convert mirror position and normal in world space - const MT_Matrix3x3 & mirrorObjWorldOri = m_mirror->GetSGNode()->GetWorldOrientation(); - const MT_Point3 & mirrorObjWorldPos = m_mirror->GetSGNode()->GetWorldPosition(); - const MT_Vector3 & mirrorObjWorldScale = m_mirror->GetSGNode()->GetWorldScaling(); - MT_Point3 mirrorWorldPos = - mirrorObjWorldPos + mirrorObjWorldScale * (mirrorObjWorldOri * m_mirrorPos); - MT_Vector3 mirrorWorldZ = mirrorObjWorldOri * m_mirrorZ; - // get observer world position - const MT_Point3 & observerWorldPos = m_observer->GetSGNode()->GetWorldPosition(); - // get plane D term = mirrorPos . normal - MT_Scalar mirrorPlaneDTerm = mirrorWorldPos.dot(mirrorWorldZ); - // compute distance of observer to mirror = D - observerPos . normal - MT_Scalar observerDistance = mirrorPlaneDTerm - observerWorldPos.dot(mirrorWorldZ); - // if distance < 0.01 => observer is on wrong side of mirror, don't render - if (observerDistance < 0.01f) - return; - // set camera world position = observerPos + normal * 2 * distance - MT_Point3 cameraWorldPos = observerWorldPos + (MT_Scalar(2.0)*observerDistance)*mirrorWorldZ; - m_camera->GetSGNode()->SetLocalPosition(cameraWorldPos); - // set camera orientation: z=normal, y=mirror_up in world space, x= y x z - MT_Vector3 mirrorWorldY = mirrorObjWorldOri * m_mirrorY; - MT_Vector3 mirrorWorldX = mirrorObjWorldOri * m_mirrorX; - MT_Matrix3x3 cameraWorldOri( - mirrorWorldX[0], mirrorWorldY[0], mirrorWorldZ[0], - mirrorWorldX[1], mirrorWorldY[1], mirrorWorldZ[1], - mirrorWorldX[2], mirrorWorldY[2], mirrorWorldZ[2]); - m_camera->GetSGNode()->SetLocalOrientation(cameraWorldOri); - m_camera->GetSGNode()->UpdateWorldData(0.0); - // compute camera frustrum: - // get position of mirror relative to camera: offset = mirrorPos-cameraPos - MT_Vector3 mirrorOffset = mirrorWorldPos - cameraWorldPos; - // convert to camera orientation - mirrorOffset = mirrorOffset * cameraWorldOri; - // scale mirror size to world scale: - // get closest local axis for mirror Y and X axis and scale height and width by local axis scale - MT_Scalar x, y; - x = fabs(m_mirrorY[0]); - y = fabs(m_mirrorY[1]); - float height = (x > y) ? - ((x > fabs(m_mirrorY[2])) ? mirrorObjWorldScale[0] : mirrorObjWorldScale[2]): - ((y > fabs(m_mirrorY[2])) ? mirrorObjWorldScale[1] : mirrorObjWorldScale[2]); - x = fabs(m_mirrorX[0]); - y = fabs(m_mirrorX[1]); - float width = (x > y) ? - ((x > fabs(m_mirrorX[2])) ? mirrorObjWorldScale[0] : mirrorObjWorldScale[2]): - ((y > fabs(m_mirrorX[2])) ? mirrorObjWorldScale[1] : mirrorObjWorldScale[2]); - width *= m_mirrorHalfWidth; - height *= m_mirrorHalfHeight; - // left = offsetx-width - // right = offsetx+width - // top = offsety+height - // bottom = offsety-height - // near = -offsetz - // far = near+100 - frustrum.x1 = mirrorOffset[0]-width; - frustrum.x2 = mirrorOffset[0]+width; - frustrum.y1 = mirrorOffset[1]-height; - frustrum.y2 = mirrorOffset[1]+height; - frustrum.camnear = -mirrorOffset[2]; - frustrum.camfar = -mirrorOffset[2]+m_clip; - } + if (m_mirror) + { + // mirror mode, compute camera frustrum, position and orientation + // convert mirror position and normal in world space + const MT_Matrix3x3 & mirrorObjWorldOri = m_mirror->GetSGNode()->GetWorldOrientation(); + const MT_Point3 & mirrorObjWorldPos = m_mirror->GetSGNode()->GetWorldPosition(); + const MT_Vector3 & mirrorObjWorldScale = m_mirror->GetSGNode()->GetWorldScaling(); + MT_Point3 mirrorWorldPos = + mirrorObjWorldPos + mirrorObjWorldScale * (mirrorObjWorldOri * m_mirrorPos); + MT_Vector3 mirrorWorldZ = mirrorObjWorldOri * m_mirrorZ; + // get observer world position + const MT_Point3 & observerWorldPos = m_observer->GetSGNode()->GetWorldPosition(); + // get plane D term = mirrorPos . normal + MT_Scalar mirrorPlaneDTerm = mirrorWorldPos.dot(mirrorWorldZ); + // compute distance of observer to mirror = D - observerPos . normal + MT_Scalar observerDistance = mirrorPlaneDTerm - observerWorldPos.dot(mirrorWorldZ); + // if distance < 0.01 => observer is on wrong side of mirror, don't render + if (observerDistance < 0.01f) + return; + // set camera world position = observerPos + normal * 2 * distance + MT_Point3 cameraWorldPos = observerWorldPos + (MT_Scalar(2.0)*observerDistance)*mirrorWorldZ; + m_camera->GetSGNode()->SetLocalPosition(cameraWorldPos); + // set camera orientation: z=normal, y=mirror_up in world space, x= y x z + MT_Vector3 mirrorWorldY = mirrorObjWorldOri * m_mirrorY; + MT_Vector3 mirrorWorldX = mirrorObjWorldOri * m_mirrorX; + MT_Matrix3x3 cameraWorldOri( + mirrorWorldX[0], mirrorWorldY[0], mirrorWorldZ[0], + mirrorWorldX[1], mirrorWorldY[1], mirrorWorldZ[1], + mirrorWorldX[2], mirrorWorldY[2], mirrorWorldZ[2]); + m_camera->GetSGNode()->SetLocalOrientation(cameraWorldOri); + m_camera->GetSGNode()->UpdateWorldData(0.0); + // compute camera frustrum: + // get position of mirror relative to camera: offset = mirrorPos-cameraPos + MT_Vector3 mirrorOffset = mirrorWorldPos - cameraWorldPos; + // convert to camera orientation + mirrorOffset = mirrorOffset * cameraWorldOri; + // scale mirror size to world scale: + // get closest local axis for mirror Y and X axis and scale height and width by local axis scale + MT_Scalar x, y; + x = fabs(m_mirrorY[0]); + y = fabs(m_mirrorY[1]); + float height = (x > y) ? + ((x > fabs(m_mirrorY[2])) ? mirrorObjWorldScale[0] : mirrorObjWorldScale[2]): + ((y > fabs(m_mirrorY[2])) ? mirrorObjWorldScale[1] : mirrorObjWorldScale[2]); + x = fabs(m_mirrorX[0]); + y = fabs(m_mirrorX[1]); + float width = (x > y) ? + ((x > fabs(m_mirrorX[2])) ? mirrorObjWorldScale[0] : mirrorObjWorldScale[2]): + ((y > fabs(m_mirrorX[2])) ? mirrorObjWorldScale[1] : mirrorObjWorldScale[2]); + width *= m_mirrorHalfWidth; + height *= m_mirrorHalfHeight; + // left = offsetx-width + // right = offsetx+width + // top = offsety+height + // bottom = offsety-height + // near = -offsetz + // far = near+100 + frustrum.x1 = mirrorOffset[0]-width; + frustrum.x2 = mirrorOffset[0]+width; + frustrum.y1 = mirrorOffset[1]-height; + frustrum.y2 = mirrorOffset[1]+height; + frustrum.camnear = -mirrorOffset[2]; + frustrum.camfar = -mirrorOffset[2]+m_clip; + } // Store settings to be restored later - const RAS_IRasterizer::StereoMode stereomode = m_rasterizer->GetStereoMode(); + const RAS_IRasterizer::StereoMode stereomode = m_rasterizer->GetStereoMode(); RAS_Rect area = m_canvas->GetWindowArea(); - // The screen area that ImageViewport will copy is also the rendering zone - m_canvas->SetViewPort(m_position[0], m_position[1], m_position[0]+m_capSize[0]-1, m_position[1]+m_capSize[1]-1); - m_canvas->ClearColor(m_background[0], m_background[1], m_background[2], m_background[3]); - m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER); - m_rasterizer->BeginFrame(RAS_IRasterizer::KX_TEXTURED,m_engine->GetClockTime()); - m_rendertools->BeginFrame(m_rasterizer); - m_engine->SetWorldSettings(m_scene->GetWorldInfo()); - m_rendertools->SetAuxilaryClientInfo(m_scene); - m_rasterizer->DisplayFog(); - // matrix calculation, don't apply any of the stereo mode - m_rasterizer->SetStereoMode(RAS_IRasterizer::RAS_STEREO_NOSTEREO); - if (m_mirror) - { - // frustrum was computed above - // get frustrum matrix and set projection matrix + // The screen area that ImageViewport will copy is also the rendering zone + m_canvas->SetViewPort(m_position[0], m_position[1], m_position[0]+m_capSize[0]-1, m_position[1]+m_capSize[1]-1); + m_canvas->ClearColor(m_background[0], m_background[1], m_background[2], m_background[3]); + m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER); + m_rasterizer->BeginFrame(RAS_IRasterizer::KX_TEXTURED,m_engine->GetClockTime()); + m_rendertools->BeginFrame(m_rasterizer); + m_engine->SetWorldSettings(m_scene->GetWorldInfo()); + m_rendertools->SetAuxilaryClientInfo(m_scene); + m_rasterizer->DisplayFog(); + // matrix calculation, don't apply any of the stereo mode + m_rasterizer->SetStereoMode(RAS_IRasterizer::RAS_STEREO_NOSTEREO); + if (m_mirror) + { + // frustrum was computed above + // get frustrum matrix and set projection matrix MT_Matrix4x4 projmat = m_rasterizer->GetFrustumMatrix( - frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); + frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); m_camera->SetProjectionMatrix(projmat); - } else if (m_camera->hasValidProjectionMatrix()) + } else if (m_camera->hasValidProjectionMatrix()) { m_rasterizer->SetProjectionMatrix(m_camera->GetProjectionMatrix()); - } else - { + } else + { float lens = m_camera->GetLens(); bool orthographic = !m_camera->GetCameraData()->m_perspective; float nearfrust = m_camera->GetCameraNear(); float farfrust = m_camera->GetCameraFar(); - float aspect_ratio = 1.0f; - Scene *blenderScene = m_scene->GetBlenderScene(); + float aspect_ratio = 1.0f; + Scene *blenderScene = m_scene->GetBlenderScene(); MT_Matrix4x4 projmat; // compute the aspect ratio from frame blender scene settings so that render to texture - // works the same in Blender and in Blender player - if (blenderScene->r.ysch != 0) - aspect_ratio = float(blenderScene->r.xsch*blenderScene->r.xasp) / float(blenderScene->r.ysch*blenderScene->r.yasp); + // works the same in Blender and in Blender player + if (blenderScene->r.ysch != 0) + aspect_ratio = float(blenderScene->r.xsch*blenderScene->r.xasp) / float(blenderScene->r.ysch*blenderScene->r.yasp); if (orthographic) { RAS_FramingManager::ComputeDefaultOrtho( - nearfrust, - farfrust, - m_camera->GetScale(), - aspect_ratio, - frustrum - ); + nearfrust, + farfrust, + m_camera->GetScale(), + aspect_ratio, + frustrum + ); projmat = m_rasterizer->GetOrthoMatrix( - frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); - } else + frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); + } else { RAS_FramingManager::ComputeDefaultFrustum( - nearfrust, - farfrust, - lens, - aspect_ratio, - frustrum); + nearfrust, + farfrust, + lens, + aspect_ratio, + frustrum); projmat = m_rasterizer->GetFrustumMatrix( - frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); + frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); } m_camera->SetProjectionMatrix(projmat); } @@ -257,8 +257,8 @@ void ImageRender::Render() m_rasterizer->SetViewMatrix(viewmat, m_camera->NodeGetWorldOrientation(), m_camera->NodeGetWorldPosition(), m_camera->GetCameraData()->m_perspective); m_camera->SetModelviewMatrix(viewmat); - // restore the stereo mode now that the matrix is computed - m_rasterizer->SetStereoMode(stereomode); + // restore the stereo mode now that the matrix is computed + m_rasterizer->SetStereoMode(stereomode); m_scene->CalculateVisibleMeshes(m_rasterizer,m_camera); @@ -328,11 +328,11 @@ static int ImageRender_init (PyObject * pySelf, PyObject * args, PyObject * kwds // get background color PyObject * getBackground (PyImage * self, void * closure) { - return Py_BuildValue("[BBBB]", - getImageRender(self)->getBackground(0), - getImageRender(self)->getBackground(1), - getImageRender(self)->getBackground(2), - getImageRender(self)->getBackground(3)); + return Py_BuildValue("[BBBB]", + getImageRender(self)->getBackground(0), + getImageRender(self)->getBackground(1), + getImageRender(self)->getBackground(2), + getImageRender(self)->getBackground(3)); } // set color @@ -433,24 +433,24 @@ static int ImageMirror_init (PyObject * pySelf, PyObject * args, PyObject * kwds PyObject * scene; // reference object for mirror PyObject * observer; - // object holding the mirror - PyObject * mirror; - // material of the mirror - short materialID = 0; + // object holding the mirror + PyObject * mirror; + // material of the mirror + short materialID = 0; // parameter keywords static const char *kwlist[] = {"scene", "observer", "mirror", "material", NULL}; // get parameters if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOO|h", - const_cast(kwlist), &scene, &observer, &mirror, &materialID)) + const_cast(kwlist), &scene, &observer, &mirror, &materialID)) return -1; try { // get scene pointer KX_Scene * scenePtr (NULL); - if (scene != NULL && PyObject_TypeCheck(scene, &KX_Scene::Type)) - scenePtr = static_castBGE_PROXY_REF(scene); + if (scene != NULL && PyObject_TypeCheck(scene, &KX_Scene::Type)) + scenePtr = static_castBGE_PROXY_REF(scene); else - THRWEXCP(SceneInvalid, S_OK); + THRWEXCP(SceneInvalid, S_OK); if(scenePtr==NULL) /* incase the python proxy reference is invalid */ THRWEXCP(SceneInvalid, S_OK); @@ -458,11 +458,11 @@ static int ImageMirror_init (PyObject * pySelf, PyObject * args, PyObject * kwds // get observer pointer KX_GameObject * observerPtr (NULL); if (observer != NULL && PyObject_TypeCheck(observer, &KX_GameObject::Type)) - observerPtr = static_castBGE_PROXY_REF(observer); - else if (observer != NULL && PyObject_TypeCheck(observer, &KX_Camera::Type)) - observerPtr = static_castBGE_PROXY_REF(observer); + observerPtr = static_castBGE_PROXY_REF(observer); + else if (observer != NULL && PyObject_TypeCheck(observer, &KX_Camera::Type)) + observerPtr = static_castBGE_PROXY_REF(observer); else - THRWEXCP(ObserverInvalid, S_OK); + THRWEXCP(ObserverInvalid, S_OK); if(observerPtr==NULL) /* incase the python proxy reference is invalid */ THRWEXCP(ObserverInvalid, S_OK); @@ -470,27 +470,27 @@ static int ImageMirror_init (PyObject * pySelf, PyObject * args, PyObject * kwds // get mirror pointer KX_GameObject * mirrorPtr (NULL); if (mirror != NULL && PyObject_TypeCheck(mirror, &KX_GameObject::Type)) - mirrorPtr = static_castBGE_PROXY_REF(mirror); + mirrorPtr = static_castBGE_PROXY_REF(mirror); else - THRWEXCP(MirrorInvalid, S_OK); + THRWEXCP(MirrorInvalid, S_OK); if(mirrorPtr==NULL) /* incase the python proxy reference is invalid */ THRWEXCP(MirrorInvalid, S_OK); - // locate the material in the mirror + // locate the material in the mirror RAS_IPolyMaterial * material = getMaterial(mirror, materialID); if (material == NULL) - THRWEXCP(MaterialNotAvail, S_OK); + THRWEXCP(MaterialNotAvail, S_OK); // get pointer to image structure PyImage * self = reinterpret_cast(pySelf); // create source object - if (self->m_image != NULL) - { - delete self->m_image; - self->m_image = NULL; - } + if (self->m_image != NULL) + { + delete self->m_image; + self->m_image = NULL; + } self->m_image = new ImageRender(scenePtr, observerPtr, mirrorPtr, material); } catch (Exception & exp) @@ -530,7 +530,7 @@ static PyGetSetDef imageMirrorGetSets[] = {(char*)"clip", (getter)getClip, (setter)setClip, (char*)"clipping distance", NULL}, // attribute from ImageRender {(char*)"background", (getter)getBackground, (setter)setBackground, (char*)"background color", NULL}, - // attribute from ImageViewport + // attribute from ImageViewport {(char*)"capsize", (getter)ImageViewport_getCaptureSize, (setter)ImageViewport_setCaptureSize, (char*)"size of render area", NULL}, {(char*)"alpha", (getter)ImageViewport_getAlpha, (setter)ImageViewport_setAlpha, (char*)"use alpha in texture", NULL}, {(char*)"whole", (getter)ImageViewport_getWhole, (setter)ImageViewport_setWhole, (char*)"use whole viewport to render", NULL}, @@ -552,164 +552,164 @@ ImageRender::ImageRender (KX_Scene * scene, KX_GameObject * observer, KX_GameObj m_scene(scene), m_observer(observer), m_mirror(mirror), - m_clip(100.f) + m_clip(100.f) { - // this constructor is used for automatic planar mirror - // create a camera, take all data by default, in any case we will recompute the frustrum on each frame + // this constructor is used for automatic planar mirror + // create a camera, take all data by default, in any case we will recompute the frustrum on each frame RAS_CameraData camdata; - vector mirrorVerts; - vector::iterator it; - float mirrorArea = 0.f; - float mirrorNormal[3] = {0.f, 0.f, 0.f}; - float mirrorUp[3]; - float dist, vec[3], axis[3]; - float zaxis[3] = {0.f, 0.f, 1.f}; - float yaxis[3] = {0.f, 1.f, 0.f}; - float mirrorMat[3][3]; - float left, right, top, bottom, back; + vector mirrorVerts; + vector::iterator it; + float mirrorArea = 0.f; + float mirrorNormal[3] = {0.f, 0.f, 0.f}; + float mirrorUp[3]; + float dist, vec[3], axis[3]; + float zaxis[3] = {0.f, 0.f, 1.f}; + float yaxis[3] = {0.f, 1.f, 0.f}; + float mirrorMat[3][3]; + float left, right, top, bottom, back; // make sure this camera will delete its node m_camera= new KX_Camera(scene, KX_Scene::m_callbacks, camdata, true, true); m_camera->SetName("__mirror__cam__"); - // don't add the camera to the scene object list, it doesn't need to be accessible - m_owncamera = true; - // retrieve rendering objects - m_engine = KX_GetActiveEngine(); - m_rasterizer = m_engine->GetRasterizer(); - m_canvas = m_engine->GetCanvas(); - m_rendertools = m_engine->GetRenderTools(); - // locate the vertex assigned to mat and do following calculation in mesh coordinates - for (int meshIndex = 0; meshIndex < mirror->GetMeshCount(); meshIndex++) - { - RAS_MeshObject* mesh = mirror->GetMesh(meshIndex); - int numPolygons = mesh->NumPolygons(); - for (int polygonIndex=0; polygonIndex < numPolygons; polygonIndex++) - { - RAS_Polygon* polygon = mesh->GetPolygon(polygonIndex); - if (polygon->GetMaterial()->GetPolyMaterial() == mat) - { - RAS_TexVert *v1, *v2, *v3, *v4; - float normal[3]; - float area; - // this polygon is part of the mirror, - v1 = polygon->GetVertex(0); - v2 = polygon->GetVertex(1); - v3 = polygon->GetVertex(2); - mirrorVerts.push_back(v1); - mirrorVerts.push_back(v2); - mirrorVerts.push_back(v3); - if (polygon->VertexCount() == 4) - { - v4 = polygon->GetVertex(3); - mirrorVerts.push_back(v4); - area = normal_quad_v3( normal,(float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ(), (float*)v4->getXYZ()); - } else - { - area = normal_tri_v3( normal,(float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ()); - } - area = fabs(area); - mirrorArea += area; - mul_v3_fl(normal, area); - add_v3_v3v3(mirrorNormal, mirrorNormal, normal); - } - } - } - if (mirrorVerts.size() == 0 || mirrorArea < FLT_EPSILON) - { - // no vertex or zero size mirror - THRWEXCP(MirrorSizeInvalid, S_OK); - } - // compute average normal of mirror faces - mul_v3_fl(mirrorNormal, 1.0f/mirrorArea); - if (normalize_v3(mirrorNormal) == 0.f) - { - // no normal - THRWEXCP(MirrorNormalInvalid, S_OK); - } - // the mirror plane has an equation of the type ax+by+cz = d where (a,b,c) is the normal vector + // don't add the camera to the scene object list, it doesn't need to be accessible + m_owncamera = true; + // retrieve rendering objects + m_engine = KX_GetActiveEngine(); + m_rasterizer = m_engine->GetRasterizer(); + m_canvas = m_engine->GetCanvas(); + m_rendertools = m_engine->GetRenderTools(); + // locate the vertex assigned to mat and do following calculation in mesh coordinates + for (int meshIndex = 0; meshIndex < mirror->GetMeshCount(); meshIndex++) + { + RAS_MeshObject* mesh = mirror->GetMesh(meshIndex); + int numPolygons = mesh->NumPolygons(); + for (int polygonIndex=0; polygonIndex < numPolygons; polygonIndex++) + { + RAS_Polygon* polygon = mesh->GetPolygon(polygonIndex); + if (polygon->GetMaterial()->GetPolyMaterial() == mat) + { + RAS_TexVert *v1, *v2, *v3, *v4; + float normal[3]; + float area; + // this polygon is part of the mirror, + v1 = polygon->GetVertex(0); + v2 = polygon->GetVertex(1); + v3 = polygon->GetVertex(2); + mirrorVerts.push_back(v1); + mirrorVerts.push_back(v2); + mirrorVerts.push_back(v3); + if (polygon->VertexCount() == 4) + { + v4 = polygon->GetVertex(3); + mirrorVerts.push_back(v4); + area = normal_quad_v3( normal,(float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ(), (float*)v4->getXYZ()); + } else + { + area = normal_tri_v3( normal,(float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ()); + } + area = fabs(area); + mirrorArea += area; + mul_v3_fl(normal, area); + add_v3_v3v3(mirrorNormal, mirrorNormal, normal); + } + } + } + if (mirrorVerts.size() == 0 || mirrorArea < FLT_EPSILON) + { + // no vertex or zero size mirror + THRWEXCP(MirrorSizeInvalid, S_OK); + } + // compute average normal of mirror faces + mul_v3_fl(mirrorNormal, 1.0f/mirrorArea); + if (normalize_v3(mirrorNormal) == 0.f) + { + // no normal + THRWEXCP(MirrorNormalInvalid, S_OK); + } + // the mirror plane has an equation of the type ax+by+cz = d where (a,b,c) is the normal vector // if the mirror is more vertical then horizontal, the Z axis is the up direction. // otherwise the Y axis is the up direction. // If the mirror is not perfectly vertical(horizontal), the Z(Y) axis projection on the mirror // plan by the normal will be the up direction. if (fabs(mirrorNormal[2]) > fabs(mirrorNormal[1]) && - fabs(mirrorNormal[2]) > fabs(mirrorNormal[0])) + fabs(mirrorNormal[2]) > fabs(mirrorNormal[0])) { // the mirror is more horizontal than vertical - copy_v3_v3(axis, yaxis); + copy_v3_v3(axis, yaxis); } else { // the mirror is more vertical than horizontal - copy_v3_v3(axis, zaxis); + copy_v3_v3(axis, zaxis); } - dist = dot_v3v3(mirrorNormal, axis); - if (fabs(dist) < FLT_EPSILON) - { - // the mirror is already fully aligned with up axis - copy_v3_v3(mirrorUp, axis); - } - else - { - // projection of axis to mirror plane through normal - copy_v3_v3(vec, mirrorNormal); - mul_v3_fl(vec, dist); - sub_v3_v3v3(mirrorUp, axis, vec); - if (normalize_v3(mirrorUp) == 0.f) - { - // should not happen - THRWEXCP(MirrorHorizontal, S_OK); - return; - } - } - // compute rotation matrix between local coord and mirror coord - // to match camera orientation, we select mirror z = -normal, y = up, x = y x z - negate_v3_v3(mirrorMat[2], mirrorNormal); - copy_v3_v3(mirrorMat[1], mirrorUp); - cross_v3_v3v3(mirrorMat[0], mirrorMat[1], mirrorMat[2]); - // transpose to make it a orientation matrix from local space to mirror space - transpose_m3(mirrorMat); - // transform all vertex to plane coordinates and determine mirror position - left = FLT_MAX; - right = -FLT_MAX; - bottom = FLT_MAX; - top = -FLT_MAX; - back = -FLT_MAX; // most backward vertex (=highest Z coord in mirror space) - for (it = mirrorVerts.begin(); it != mirrorVerts.end(); it++) - { - copy_v3_v3(vec, (float*)(*it)->getXYZ()); - mul_m3_v3(mirrorMat, vec); - if (vec[0] < left) - left = vec[0]; - if (vec[0] > right) - right = vec[0]; - if (vec[1] < bottom) - bottom = vec[1]; - if (vec[1] > top) - top = vec[1]; - if (vec[2] > back) - back = vec[2]; - } - // now store this information in the object for later rendering - m_mirrorHalfWidth = (right-left)*0.5f; - m_mirrorHalfHeight = (top-bottom)*0.5f; - if (m_mirrorHalfWidth < 0.01f || m_mirrorHalfHeight < 0.01f) - { - // mirror too small - THRWEXCP(MirrorTooSmall, S_OK); - } - // mirror position in mirror coord - vec[0] = (left+right)*0.5f; - vec[1] = (top+bottom)*0.5f; - vec[2] = back; - // convert it in local space: transpose again the matrix to get back to mirror to local transform - transpose_m3(mirrorMat); - mul_m3_v3(mirrorMat, vec); - // mirror position in local space - m_mirrorPos.setValue(vec[0], vec[1], vec[2]); - // mirror normal vector (pointed towards the back of the mirror) in local space - m_mirrorZ.setValue(-mirrorNormal[0], -mirrorNormal[1], -mirrorNormal[2]); - m_mirrorY.setValue(mirrorUp[0], mirrorUp[1], mirrorUp[2]); - m_mirrorX = m_mirrorY.cross(m_mirrorZ); - m_render = true; + dist = dot_v3v3(mirrorNormal, axis); + if (fabs(dist) < FLT_EPSILON) + { + // the mirror is already fully aligned with up axis + copy_v3_v3(mirrorUp, axis); + } + else + { + // projection of axis to mirror plane through normal + copy_v3_v3(vec, mirrorNormal); + mul_v3_fl(vec, dist); + sub_v3_v3v3(mirrorUp, axis, vec); + if (normalize_v3(mirrorUp) == 0.f) + { + // should not happen + THRWEXCP(MirrorHorizontal, S_OK); + return; + } + } + // compute rotation matrix between local coord and mirror coord + // to match camera orientation, we select mirror z = -normal, y = up, x = y x z + negate_v3_v3(mirrorMat[2], mirrorNormal); + copy_v3_v3(mirrorMat[1], mirrorUp); + cross_v3_v3v3(mirrorMat[0], mirrorMat[1], mirrorMat[2]); + // transpose to make it a orientation matrix from local space to mirror space + transpose_m3(mirrorMat); + // transform all vertex to plane coordinates and determine mirror position + left = FLT_MAX; + right = -FLT_MAX; + bottom = FLT_MAX; + top = -FLT_MAX; + back = -FLT_MAX; // most backward vertex (=highest Z coord in mirror space) + for (it = mirrorVerts.begin(); it != mirrorVerts.end(); it++) + { + copy_v3_v3(vec, (float*)(*it)->getXYZ()); + mul_m3_v3(mirrorMat, vec); + if (vec[0] < left) + left = vec[0]; + if (vec[0] > right) + right = vec[0]; + if (vec[1] < bottom) + bottom = vec[1]; + if (vec[1] > top) + top = vec[1]; + if (vec[2] > back) + back = vec[2]; + } + // now store this information in the object for later rendering + m_mirrorHalfWidth = (right-left)*0.5f; + m_mirrorHalfHeight = (top-bottom)*0.5f; + if (m_mirrorHalfWidth < 0.01f || m_mirrorHalfHeight < 0.01f) + { + // mirror too small + THRWEXCP(MirrorTooSmall, S_OK); + } + // mirror position in mirror coord + vec[0] = (left+right)*0.5f; + vec[1] = (top+bottom)*0.5f; + vec[2] = back; + // convert it in local space: transpose again the matrix to get back to mirror to local transform + transpose_m3(mirrorMat); + mul_m3_v3(mirrorMat, vec); + // mirror position in local space + m_mirrorPos.setValue(vec[0], vec[1], vec[2]); + // mirror normal vector (pointed towards the back of the mirror) in local space + m_mirrorZ.setValue(-mirrorNormal[0], -mirrorNormal[1], -mirrorNormal[2]); + m_mirrorY.setValue(mirrorUp[0], mirrorUp[1], mirrorUp[2]); + m_mirrorX = m_mirrorY.cross(m_mirrorZ); + m_render = true; setBackground(0, 0, 255, 255); } diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index d0e5ee74f6e..0276ad6fd6b 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -123,34 +123,34 @@ void ImageViewport::calcImage (unsigned int texId, double ts) } // if texture can be directly created if (texId != 0 && m_pyfilter == NULL && m_capSize[0] == calcSize(m_capSize[0]) - && m_capSize[1] == calcSize(m_capSize[1]) && !m_flip) + && m_capSize[1] == calcSize(m_capSize[1]) && !m_flip) { // just copy current viewport to texture - glBindTexture(GL_TEXTURE_2D, texId); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1]); - // image is not available - m_avail = false; + glBindTexture(GL_TEXTURE_2D, texId); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1]); + // image is not available + m_avail = false; } // otherwise copy viewport to buffer, if image is not available else if (!m_avail) { // get frame buffer data - if (m_alpha) - { - glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGBA, - GL_UNSIGNED_BYTE, m_viewportImage); - // filter loaded data - FilterRGBA32 filt; - filterImage(filt, m_viewportImage, m_capSize); - } - else - { - glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGB, - GL_UNSIGNED_BYTE, m_viewportImage); - // filter loaded data - FilterRGB24 filt; - filterImage(filt, m_viewportImage, m_capSize); - } + if (m_alpha) + { + glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGBA, + GL_UNSIGNED_BYTE, m_viewportImage); + // filter loaded data + FilterRGBA32 filt; + filterImage(filt, m_viewportImage, m_capSize); + } + else + { + glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGB, + GL_UNSIGNED_BYTE, m_viewportImage); + // filter loaded data + FilterRGB24 filt; + filterImage(filt, m_viewportImage, m_capSize); + } } } diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index f8274756c8b..8a76b0c004d 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -544,11 +544,11 @@ void VideoFFmpeg::openFile (char * filename) // It would be good to find this information from the context but there are no simple indication !strncmp(filename, "http://", 7) || #ifdef FFMPEG_PB_IS_POINTER - (m_formatCtx->pb && m_formatCtx->pb->is_streamed) + (m_formatCtx->pb && m_formatCtx->pb->is_streamed) #else - m_formatCtx->pb.is_streamed + m_formatCtx->pb.is_streamed #endif - ) + ) { // the file is in fact a streaming source, treat as cam to prevent seeking m_isFile = false; diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index c1258bbb6e4..2cb3831de52 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -175,9 +175,9 @@ PyObject* initVideoTexture(void) // prepare classes registerAllTypes(); - registerAllExceptions(); + registerAllExceptions(); - if (!pyImageTypes.ready()) + if (!pyImageTypes.ready()) return NULL; if (!pyFilterTypes.ready()) return NULL; diff --git a/source/tests/check_deprecated.py b/source/tests/check_deprecated.py index 856e1f6d272..34b07518162 100644 --- a/source/tests/check_deprecated.py +++ b/source/tests/check_deprecated.py @@ -130,7 +130,7 @@ def deprecations(): def main(): import datetime - now = datetime.datetime.now()\ + now = datetime.datetime.now() deps = deprecations()