merge with trunk (15330 -> 15566)
authorMartin Poirier <theeth@yahoo.com>
Mon, 14 Jul 2008 14:09:36 +0000 (14:09 +0000)
committerMartin Poirier <theeth@yahoo.com>
Mon, 14 Jul 2008 14:09:36 +0000 (14:09 +0000)
261 files changed:
CMakeLists.txt
README
intern/bsp/intern/BSP_CSGMesh.cpp
intern/container/CTR_TaggedIndex.h
intern/decimation/intern/LOD_ManMesh2.cpp
intern/elbeem/intern/solver_init.cpp
intern/ghost/intern/GHOST_SystemWin32.cpp
intern/ghost/intern/GHOST_WindowWin32.cpp
intern/iksolver/intern/IK_QTask.h
intern/moto/include/GEN_Map.h
intern/moto/include/MT_random.h
intern/moto/intern/MT_random.cpp
projectfiles_vc7/blender/blenlib/BLI_blenlib.vcproj
projectfiles_vc7/blender/render/BRE_render.vcproj
projectfiles_vc7/blender/src/BL_src.vcproj
projectfiles_vc7/gameengine/gamelogic/SCA_GameLogic.vcproj
projectfiles_vc7/gameengine/ketsji/KX_ketsji.vcproj
projectfiles_vc7/gameengine/rasterizer/RAS_rasterizer.vcproj
release/scripts/animation_bake_constraints.py
release/scripts/c3d_import.py
release/windows/installer/00.sconsblender.nsi
source/blender/blenkernel/BKE_bmesh.h
source/blender/blenkernel/BKE_bmeshCustomData.h
source/blender/blenkernel/BKE_cloth.h
source/blender/blenkernel/BKE_customdata.h
source/blender/blenkernel/BKE_ipo.h
source/blender/blenkernel/intern/BME_Customdata.c
source/blender/blenkernel/intern/BME_conversions.c
source/blender/blenkernel/intern/BME_eulers.c
source/blender/blenkernel/intern/BME_mesh.c
source/blender/blenkernel/intern/BME_structure.c
source/blender/blenkernel/intern/BME_tools.c
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/bmesh_private.h
source/blender/blenkernel/intern/cloth.c
source/blender/blenkernel/intern/collision.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/implicit.c
source/blender/blenkernel/intern/ipo.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/sca.c
source/blender/blenkernel/intern/text.c
source/blender/blenlib/BLI_arithb.h
source/blender/blenlib/BLI_mempool.h [new file with mode: 0644]
source/blender/blenlib/BLI_winstuff.h
source/blender/blenlib/intern/BLI_kdopbvh.c
source/blender/blenlib/intern/BLI_mempool.c [new file with mode: 0644]
source/blender/blenlib/intern/arithb.c
source/blender/blenlib/intern/util.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/imbuf/intern/IMB_anim.h
source/blender/imbuf/intern/anim.c
source/blender/imbuf/intern/openexr/openexr_api.cpp
source/blender/include/BDR_drawobject.h
source/blender/include/BIF_editaction.h
source/blender/include/BIF_editarmature.h
source/blender/include/BIF_resources.h
source/blender/include/BSE_sequence.h
source/blender/include/blendef.h
source/blender/makesdna/DNA_actuator_types.h
source/blender/makesdna/DNA_controller_types.h
source/blender/makesdna/DNA_customdata_types.h
source/blender/makesdna/DNA_lamp_types.h
source/blender/makesdna/DNA_meshdata_types.h
source/blender/makesdna/DNA_sensor_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/nodes/intern/CMP_nodes/CMP_gamma.c
source/blender/nodes/intern/CMP_nodes/CMP_math.c
source/blender/python/BPY_interface.c
source/blender/python/api2_2x/CurNurb.c
source/blender/python/api2_2x/Lamp.c
source/blender/python/api2_2x/doc/Curve.py
source/blender/python/api2_2x/matrix.c
source/blender/python/api2_2x/sceneSequence.c
source/blender/radiosity/intern/source/radrender.c
source/blender/render/intern/include/pixelshading.h
source/blender/render/intern/include/render_types.h
source/blender/render/intern/include/sunsky.h [new file with mode: 0644]
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/pixelshading.c
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/sunsky.c [new file with mode: 0644]
source/blender/render/intern/source/zbuf.c
source/blender/src/buttons_editing.c
source/blender/src/buttons_logic.c
source/blender/src/buttons_object.c
source/blender/src/buttons_scene.c
source/blender/src/buttons_shading.c
source/blender/src/drawaction.c
source/blender/src/drawarmature.c
source/blender/src/drawimage.c
source/blender/src/drawobject.c
source/blender/src/drawview.c
source/blender/src/editaction.c
source/blender/src/editarmature.c
source/blender/src/editfont.c
source/blender/src/editmesh_add.c
source/blender/src/editmesh_mods.c
source/blender/src/editnla.c
source/blender/src/editseq.c
source/blender/src/editsima.c
source/blender/src/editsound.c
source/blender/src/edittime.c
source/blender/src/header_image.c
source/blender/src/header_view3d.c
source/blender/src/headerbuttons.c
source/blender/src/interface_draw.c
source/blender/src/poselib.c
source/blender/src/poseobject.c
source/blender/src/resources.c
source/blender/src/sequence.c
source/blender/src/space.c
source/blender/src/transform_conversions.c
source/blender/src/transform_snap.c
source/blender/src/usiblender.c
source/blender/src/view.c
source/blender/src/vpaint.c
source/creator/creator.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Converter/BL_ActionActuator.h
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Converter/BL_MeshDeformer.cpp
source/gameengine/Converter/BL_MeshDeformer.h
source/gameengine/Converter/BL_ShapeActionActuator.cpp
source/gameengine/Converter/BL_ShapeDeformer.cpp
source/gameengine/Converter/BL_ShapeDeformer.h
source/gameengine/Converter/BL_SkinDeformer.cpp
source/gameengine/Converter/BL_SkinDeformer.h
source/gameengine/Converter/BL_SkinMeshObject.cpp
source/gameengine/Converter/BL_SkinMeshObject.h
source/gameengine/Converter/KX_ConvertActuators.cpp
source/gameengine/Converter/KX_ConvertControllers.cpp
source/gameengine/Converter/KX_ConvertSensors.cpp
source/gameengine/Expressions/PyObjectPlus.h
source/gameengine/Expressions/Value.cpp
source/gameengine/Expressions/Value.h
source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
source/gameengine/GameLogic/SCA_2DFilterActuator.h
source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp [new file with mode: 0644]
source/gameengine/GameLogic/SCA_ActuatorEventManager.h [new file with mode: 0644]
source/gameengine/GameLogic/SCA_ActuatorSensor.cpp [new file with mode: 0644]
source/gameengine/GameLogic/SCA_ActuatorSensor.h [new file with mode: 0644]
source/gameengine/GameLogic/SCA_EventManager.cpp
source/gameengine/GameLogic/SCA_EventManager.h
source/gameengine/GameLogic/SCA_IActuator.h
source/gameengine/GameLogic/SCA_IController.cpp
source/gameengine/GameLogic/SCA_ILogicBrick.cpp
source/gameengine/GameLogic/SCA_ILogicBrick.h
source/gameengine/GameLogic/SCA_IObject.cpp
source/gameengine/GameLogic/SCA_IObject.h
source/gameengine/GameLogic/SCA_ISensor.cpp
source/gameengine/GameLogic/SCA_ISensor.h
source/gameengine/GameLogic/SCA_JoystickSensor.cpp
source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
source/gameengine/GameLogic/SCA_LogicManager.cpp
source/gameengine/GameLogic/SCA_MouseSensor.cpp
source/gameengine/GameLogic/SCA_NANDController.cpp [new file with mode: 0644]
source/gameengine/GameLogic/SCA_NANDController.h [new file with mode: 0644]
source/gameengine/GameLogic/SCA_NORController.cpp [new file with mode: 0644]
source/gameengine/GameLogic/SCA_NORController.h [new file with mode: 0644]
source/gameengine/GameLogic/SCA_PropertySensor.cpp
source/gameengine/GameLogic/SCA_PythonController.cpp
source/gameengine/GameLogic/SCA_PythonController.h
source/gameengine/GameLogic/SCA_XNORController.cpp [new file with mode: 0644]
source/gameengine/GameLogic/SCA_XNORController.h [new file with mode: 0644]
source/gameengine/GameLogic/SCA_XORController.cpp [new file with mode: 0644]
source/gameengine/GameLogic/SCA_XORController.h [new file with mode: 0644]
source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
source/gameengine/GamePlayer/common/GPC_RenderTools.h
source/gameengine/GamePlayer/ghost/GPG_Application.cpp
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
source/gameengine/Ketsji/BL_BlenderShader.cpp
source/gameengine/Ketsji/BL_BlenderShader.h
source/gameengine/Ketsji/BL_Material.cpp
source/gameengine/Ketsji/BL_Material.h
source/gameengine/Ketsji/BL_Shader.cpp
source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
source/gameengine/Ketsji/KX_BlenderMaterial.cpp
source/gameengine/Ketsji/KX_BlenderMaterial.h
source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
source/gameengine/Ketsji/KX_BulletPhysicsController.h
source/gameengine/Ketsji/KX_Camera.cpp
source/gameengine/Ketsji/KX_ConstraintActuator.cpp
source/gameengine/Ketsji/KX_ConstraintActuator.h
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_GameObject.h
source/gameengine/Ketsji/KX_IPO_SGController.cpp
source/gameengine/Ketsji/KX_IPO_SGController.h
source/gameengine/Ketsji/KX_IPhysicsController.h
source/gameengine/Ketsji/KX_IpoActuator.cpp
source/gameengine/Ketsji/KX_IpoActuator.h
source/gameengine/Ketsji/KX_KetsjiEngine.cpp
source/gameengine/Ketsji/KX_KetsjiEngine.h
source/gameengine/Ketsji/KX_Light.cpp
source/gameengine/Ketsji/KX_Light.h
source/gameengine/Ketsji/KX_MeshProxy.cpp
source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
source/gameengine/Ketsji/KX_NearSensor.cpp
source/gameengine/Ketsji/KX_ObjectActuator.cpp
source/gameengine/Ketsji/KX_ObjectActuator.h
source/gameengine/Ketsji/KX_ParentActuator.cpp
source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp
source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Ketsji/KX_PythonInit.h
source/gameengine/Ketsji/KX_RaySensor.cpp
source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp [new file with mode: 0644]
source/gameengine/Ketsji/KX_SCA_DynamicActuator.h [new file with mode: 0644]
source/gameengine/Ketsji/KX_Scene.cpp
source/gameengine/Ketsji/KX_Scene.h
source/gameengine/Ketsji/KX_SoundActuator.cpp
source/gameengine/Ketsji/KX_SumoPhysicsController.h
source/gameengine/Ketsji/KX_TouchEventManager.cpp
source/gameengine/Ketsji/KX_TouchSensor.cpp
source/gameengine/Ketsji/KX_TrackToActuator.cpp
source/gameengine/Ketsji/KX_VehicleWrapper.cpp
source/gameengine/PyDoc/BL_ActionActuator.py
source/gameengine/PyDoc/KX_GameObject.py
source/gameengine/PyDoc/SCA_PythonController.py
source/gameengine/Rasterizer/CMakeLists.txt
source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
source/gameengine/Rasterizer/RAS_2DFilterManager.h
source/gameengine/Rasterizer/RAS_BucketManager.cpp
source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
source/gameengine/Rasterizer/RAS_IRasterizer.h
source/gameengine/Rasterizer/RAS_IRenderTools.h
source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
source/gameengine/Rasterizer/RAS_MaterialBucket.h
source/gameengine/Rasterizer/RAS_MeshObject.cpp
source/gameengine/Rasterizer/RAS_MeshObject.h
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h
source/gameengine/Rasterizer/RAS_TexVert.cpp
source/gameengine/Rasterizer/RAS_TexVert.h
source/gameengine/Rasterizer/SConscript
source/gameengine/SceneGraph/SG_Controller.h
source/kernel/gen_system/GEN_HashedPtr.h
source/kernel/gen_system/GEN_Map.h
tools/Blender.py

index b58fe9456639abdd060aa9f9f6812e3083a54bbb..5a23e77d9f81fa04100e840f1bab164e442a317f 100644 (file)
@@ -197,10 +197,17 @@ IF(UNIX)
 ENDIF(UNIX)
 
 IF(WIN32)
-  INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
 
+  INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
+  
   SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
 
+  # Setup 64bit and 64bit windows systems
+  IF(CMAKE_CL_64)
+    message("64 bit compiler detected.")
+    SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
+  ENDIF(CMAKE_CL_64)
+
   SET(PYTHON ${LIBDIR}/python)
   SET(PYTHON_VERSION 2.5)
   SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
@@ -214,12 +221,20 @@ IF(WIN32)
   SET(OPENAL_LIB openal_static)
   SET(OPENAL_LIBPATH ${OPENAL}/lib)
 
-  SET(PNG_LIB libpng_st)
+  IF(CMAKE_CL_64)
+       SET(PNG_LIB libpng)
+  ELSE(CMAKE_CL_64)
+       SET(PNG_LIB libpng_st)
+  ENDIF(CMAKE_CL_64)
   SET(JPEG_LIB libjpeg)
 
   SET(ZLIB ${LIBDIR}/zlib)
   SET(ZLIB_INC ${ZLIB}/include)
-  SET(ZLIB_LIB libz)
+  IF(CMAKE_CL_64)
+       SET(ZLIB_LIB zlib)
+  ELSE(CMAKE_CL_64)
+       SET(ZLIB_LIB libz)
+  ENDIF(CMAKE_CL_64)
   SET(ZLIB_LIBPATH ${ZLIB}/lib)
   
   SET(PTHREADS ${LIBDIR}/pthreads)
@@ -302,7 +317,11 @@ IF(WIN32)
   
   SET(WINTAB_INC ${LIBDIR}/wintab/include) 
 
-  SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib")
+  IF(CMAKE_CL_64)
+  SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib;MSVCRT.lib ")
+  ELSE(CMAKE_CL_64)
+  SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
+  ENDIF(CMAKE_CL_64)
   SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
 ENDIF(WIN32)
 
diff --git a/README b/README
index d123a90ba486eff7251016859e56a26280b6fb61..1a7964f954e4a2366d58e8295aefff6f92786cfd 100644 (file)
--- a/README
+++ b/README
@@ -24,22 +24,22 @@ dir to one of these locations (your home directory being recommended).
 -------------------------------------Links--------------------------------------
 
 Getting Involved:
-http://www.blender.org/docs/get_involved.html
+http://www.blender.org/community/get-involved
 
 Community:
-http://www.blender3d.org/Community/
+http://www.blender.org/Community
 
 Main blender development site:
-http://www.blender.org/
+http://www.blender.org
 
 The Blender project homepage:
-http://projects.blender.org/projects/bf-blender/
+http://projects.blender.org/projects/bf-blender
 
 Documentation:
-http://www.blender.org/modules.php?op=modload&name=documentation&file=index
+http://www.blender.org/education-help
 
 Bug tracker:
-http://projects.blender.org/tracker/?atid=125&group_id=9&func=browse
+http://www.blender.org/development/report-a-bug
 
 Feature request tracker:
-http://projects.blender.org/tracker/?atid=128&group_id=9&func=browse
+http://wiki.blender.org/index.php/Requests
index 553f39a4642e1a8ae73c3f1f5baeecf51d3fbc10..ca7795b3cf5edea6b29dfa9caab4fd1e6accf674 100644 (file)
@@ -197,7 +197,7 @@ BuildEdges(
 
                for (int vert = 0; vert < vertex_num; ++vert) {
 
-                       BSP_FaceInd fi(f_it - f_it_begin);
+                       BSP_FaceInd fi(size_t (f_it - f_it_begin));
                        InsertEdge(prev_vi,face.m_verts[vert],fi,dummy);
                        prev_vi = face.m_verts[vert];
                }
index 7a7bd85e8902d02347f067f1080babe2548ebef5..68d2536c8793fb37d526295a0ac6d7aa0562cc36 100644 (file)
@@ -93,6 +93,16 @@ public:
        }
 
 
+#if defined(_WIN64)
+       CTR_TaggedIndex(
+               const unsigned __int64 val
+       ) :
+               m_val ( ((unsigned __int64)val & index_mask)
+                               | ( (empty_tag << tag_shift)
+                                       & (~index_mask) ) ) {
+       }
+#endif
+
        CTR_TaggedIndex(
                const CTR_TaggedIndex &my_index
        ):
@@ -124,6 +134,12 @@ public:
                return (long int)(m_val & index_mask);
        }
 
+#if defined(_WIN64)
+       operator unsigned __int64 () const {
+                       return (unsigned __int64)(m_val & index_mask);
+               }
+#endif
+
                bool
        IsEmpty(
        ) const {
index eeb497bb09eb1024a003b0ac6fb135d3046de0ce..2fe49b36583c47c756fa1dd498d08908fd7ccb3e 100644 (file)
@@ -477,7 +477,7 @@ DeleteVertex(
                return;
        }
 
-       LOD_VertexInd last = LOD_VertexInd(verts.end() - verts.begin() - 1);
+       LOD_VertexInd last = LOD_VertexInd(size_t(verts.end() - verts.begin() - 1));
 
        if (!(last == v)) {
 
@@ -533,7 +533,7 @@ DeleteEdge(
                return;
        }
 
-       LOD_EdgeInd last = LOD_EdgeInd(edges.end() - edges.begin() - 1);
+       LOD_EdgeInd last = LOD_EdgeInd(size_t(edges.end() - edges.begin() - 1));
 
        if (!(last == e)) {
                vector<LOD_EdgeInd> e_verts;
@@ -573,7 +573,7 @@ DeleteFace(
                return;
        }
 
-       LOD_FaceInd last = LOD_FaceInd(faces.end() - faces.begin() - 1);
+       LOD_FaceInd last = LOD_FaceInd(size_t (faces.end() - faces.begin() - 1));
 
        if (!(last == f)) {
                
index c953d2f47da66979878b645e62bfc1f28aec0679..a873f3c69874587ad84d61382ee1d2dee4f3b26a 100644 (file)
@@ -694,7 +694,7 @@ bool LbmFsgrSolver::initializeSolverMemory()
                double maxDefaultMemChunk = 2.*1024.*1024.*1024.;
                //std::cerr<<" memEstFine "<< memEstFine <<" maxWin:" <<maxWinMemChunk <<" maxMac:" <<maxMacMemChunk ; // DEBUG
 #ifdef WIN32
-               if(memEstFine> maxWinMemChunk) {
+               if(sizeof(void *)==4 && memEstFine>maxWinMemChunk) {
                        memBlockAllocProblem = true;
                }
 #endif // WIN32
index 82a76b3c7064e0e204249c6b942ef171f3fe2730..f5c7c08ebfe1d71ec5e68647413009b7485b65a5 100644 (file)
 
 #include "GHOST_SystemWin32.h"
 
+// win64 doesn't define GWL_USERDATA
+#ifdef WIN32
+#ifndef GWL_USERDATA
+#define GWL_USERDATA GWLP_USERDATA
+#define GWL_WNDPROC GWLP_WNDPROC
+#endif
+#endif
+
 /*
  * According to the docs the mouse wheel message is supported from windows 98 
  * upwards. Leaving WINVER at default value, the WM_MOUSEWHEEL message and the 
@@ -302,6 +310,15 @@ GHOST_TSuccess GHOST_SystemWin32::init()
 {
        GHOST_TSuccess success = GHOST_System::init();
 
+       /* Disable scaling on high DPI displays on Vista */
+       HMODULE user32 = ::LoadLibraryA("user32.dll");
+       typedef BOOL (WINAPI * LPFNSETPROCESSDPIAWARE)();
+       LPFNSETPROCESSDPIAWARE SetProcessDPIAware =
+               (LPFNSETPROCESSDPIAWARE)GetProcAddress(user32, "SetProcessDPIAware");
+       if (SetProcessDPIAware)
+               SetProcessDPIAware();
+       FreeLibrary(user32);
+
        // Determine whether this system has a high frequency performance counter. */
        m_hasPerformanceCounter = ::QueryPerformanceFrequency((LARGE_INTEGER*)&m_freq) == TRUE;
        if (m_hasPerformanceCounter) {
index 905b2f7ac6349487d6c1b6371690f3db4927ba27..fef58d071a457a3412c72bfbe1344e8875c4d097 100644 (file)
 #define M_PI 3.1415926536
 #endif
 
+// win64 doesn't define GWL_USERDATA
+#ifdef WIN32
+#ifndef GWL_USERDATA
+#define GWL_USERDATA GWLP_USERDATA
+#define GWL_WNDPROC GWLP_WNDPROC
+#endif
+#endif
+
 LPCSTR GHOST_WindowWin32::s_windowClassName = "GHOST_WindowClass";
 const int GHOST_WindowWin32::s_maxTitleLength = 128;
 HGLRC GHOST_WindowWin32::s_firsthGLRc = NULL;
index c291a0e7e50eb27060e2f034b273c068b1a3065a..4d469d737f8d51466f3b8e0392c771b6f10ebfbe 100644 (file)
@@ -74,7 +74,7 @@ public:
 
        virtual bool PositionTask() const { return false; }
 
-       virtual void Scale(float scale) {}
+       virtual void Scale(float) {}
 
 protected:
        int m_id;
index db3335d6110f7003943331bcadd6b13e7125bbac..9f56924419ea32be776a65f4345e26d01a140841 100644 (file)
@@ -82,6 +82,24 @@ public:
         }
         return 0;
     }
+
+    Key* getKey(int index) {
+        int count=0;
+        for (int i=0;i<m_num_buckets;i++)
+        {
+            Entry* bucket = m_buckets[i];
+            while(bucket)
+            {
+                if (count==index)
+                {
+                    return &bucket->m_key;
+                }
+                bucket = bucket->m_next;
+                count++;
+            }
+        }
+        return 0;
+    }
     
     void clear() {
         for (int i = 0; i < m_num_buckets; ++i) {
index d7da546cf03b3d9ec6be0b5444808fbcb0ce2bbe..3afe1dd16622271f3ef57ba079d846e86eb97a69 100644 (file)
 
 #include <limits.h>
 
-#define MT_RAND_MAX ULONG_MAX
+#define MT_RAND_MAX UINT_MAX
 
-extern void          MT_srand(unsigned long);
-extern unsigned long MT_rand();
+extern void          MT_srand(unsigned int);
+extern unsigned int  MT_rand();
 
 #endif
 
index 96cb394d3da324bd025e46544d6b3558266e3c52..b8302e093ca8ef1cc15d6d85c7c7818a7c14b7eb 100644 (file)
 #define TEMPERING_SHIFT_T(y)  (y << 15)
 #define TEMPERING_SHIFT_L(y)  (y >> 18)
 
-static unsigned long mt[N]; /* the array for the state vector  */
+static unsigned int mt[N]; /* the array for the state vector  */
 static int mti = N+1; /* mti==N+1 means mt[N] is not initialized */
 
 /* initializing the array with a NONZERO seed */
-void MT_srand(unsigned long seed)
+void MT_srand(unsigned int seed)
 {
     /* setting initial seeds to mt[N] using         */
     /* the generator Line 25 of Table 1 in          */
@@ -91,12 +91,12 @@ void MT_srand(unsigned long seed)
         mt[mti] = (69069 * mt[mti-1]) & 0xffffffff;
 }
 
-unsigned long MT_rand()
+unsigned int MT_rand()
 {
-    static unsigned long mag01[2] = { 0x0, MATRIX_A };
+    static unsigned int mag01[2] = { 0x0, MATRIX_A };
     /* mag01[x] = x * MATRIX_A  for x=0,1 */
 
-    unsigned long y;
+    unsigned int y;
 
     if (mti >= N) { /* generate N words at one time */
         int kk;
index 34c195cf23d9d6f5d29c78046645141b2553011b..0dfbcaa55779e145e41aa2c9f6cba7914c07c4da 100644 (file)
                        <File
                                RelativePath="..\..\..\source\blender\blenlib\intern\BLI_memarena.c">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\blender\blenlib\intern\BLI_mempool.c">
+                       </File>
                        <File
                                RelativePath="..\..\..\source\blender\blenlib\intern\boxpack2d.c">
                        </File>
                        <File
                                RelativePath="..\..\..\source\blender\blenlib\BLI_memarena.h">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\blender\blenlib\BLI_mempool.h">
+                       </File>
                        <File
                                RelativePath="..\..\..\source\blender\blenlib\intern\BLI_scanfill.h">
                        </File>
index 4869dd606f1702976081ad49390f9e9b44e23687..4331d6e15793a32ecd14e6294c22ca43921665f6 100644 (file)
@@ -74,7 +74,7 @@
                                Name="VCCLCompilerTool"
                                Optimization="0"
                                AdditionalIncludeDirectories="..\..\..\..\lib\windows\sdl\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\yafray;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\python;..\..\..\source\blender\blenkernel;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\blender\render\intern\include;..\..\..\source\blender\render\extern\include;..\..\..\source\kernel;..\..\..\source\kernel\gen_messaging"
-                               PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_QUICKTIME;WITH_OPENEXR"
+                               PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_QUICKTIME;WITH_OPENEXR;_USE_MATH_DEFINES"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="1"
                                DefaultCharIsUnsigned="TRUE"
                        <File
                                RelativePath="..\..\..\source\blender\render\intern\source\strand.c">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\blender\render\intern\source\sunsky.c">
+                       </File>
                        <File
                                RelativePath="..\..\..\source\blender\render\intern\source\texture.c">
                        </File>
                        <File
                                RelativePath="..\..\..\source\blender\render\intern\include\strand.h">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\blender\render\intern\include\sunsky.h">
+                       </File>
                        <File
                                RelativePath="..\..\..\source\blender\render\intern\include\texture.h">
                        </File>
index 6f91aeed8b55f626a67b2e8317b1da437340f851..226bedbbfd8567241622b0a864aa9d750ff6c74a 100644 (file)
@@ -21,7 +21,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                InlineFunctionExpansion="1"
-                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\build\msvc_7\intern\bsp\include;..\..\..\..\build\msvc_7\intern\ghost\include;..\..\..\..\build\msvc_7\intern\elbeem\include;..\..\..\..\build\msvc_7\intern\opennl\include;..\..\..\..\build\msvc_7\intern\bmfont\include;..\..\..\..\build\msvc_7\intern\blenkey\include;..\..\..\..\build\msvc_7\intern\decimation\include;..\..\..\..\build\msvc_7\intern\memutil\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\source\blender;..\..\..\source\blender\img;..\..\..\source\blender\verify;..\..\..\source\blender\ftfont;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\include;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\nodes;..\..\..\source\blender\blenpluginapi;..\..\..\source\blender\renderconverter;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\network;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\..\build\msvc_7\extern\verse\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include"
+                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\build\msvc_7\intern\bsp\include;..\..\..\..\build\msvc_7\intern\ghost\include;..\..\..\..\build\msvc_7\intern\elbeem\include;..\..\..\..\build\msvc_7\intern\opennl\include;..\..\..\..\build\msvc_7\intern\bmfont\include;..\..\..\..\build\msvc_7\intern\blenkey\include;..\..\..\..\build\msvc_7\intern\decimation\include;..\..\..\..\build\msvc_7\intern\memutil\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\source\blender;..\..\..\source\blender\img;..\..\..\source\blender\verify;..\..\..\source\blender\ftfont;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\include;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\nodes;..\..\..\source\blender\blenpluginapi;..\..\..\source\blender\renderconverter;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\network;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\..\build\msvc_7\extern\verse\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include"
                                PreprocessorDefinitions="NDEBUG;WIN32;_LIB;_CONSOLE;GAMEBLENDER=1;WITH_QUICKTIME;INTERNATIONAL;WITH_VERSE;WITH_OPENEXR;WITH_DDS;WITH_BULLET=1;WITH_FFMPEG"
                                StringPooling="TRUE"
                                RuntimeLibrary="0"
@@ -73,7 +73,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\build\msvc_7\intern\bsp\include;..\..\..\..\build\msvc_7\intern\ghost\include;..\..\..\..\build\msvc_7\intern\elbeem\include;..\..\..\..\build\msvc_7\intern\opennl\include;..\..\..\..\build\msvc_7\intern\bmfont\include;..\..\..\..\build\msvc_7\intern\blenkey\include;..\..\..\..\build\msvc_7\intern\decimation\include;..\..\..\..\build\msvc_7\intern\memutil\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\source\blender;..\..\..\source\blender\img;..\..\..\source\blender\verify;..\..\..\source\blender\ftfont;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\include;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\nodes;..\..\..\source\blender\blenpluginapi;..\..\..\source\blender\renderconverter;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\network;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\..\build\msvc_7\extern\verse\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include"
+                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\build\msvc_7\intern\bsp\include;..\..\..\..\build\msvc_7\intern\ghost\include;..\..\..\..\build\msvc_7\intern\elbeem\include;..\..\..\..\build\msvc_7\intern\opennl\include;..\..\..\..\build\msvc_7\intern\bmfont\include;..\..\..\..\build\msvc_7\intern\blenkey\include;..\..\..\..\build\msvc_7\intern\decimation\include;..\..\..\..\build\msvc_7\intern\memutil\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\source\blender;..\..\..\source\blender\img;..\..\..\source\blender\verify;..\..\..\source\blender\ftfont;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\include;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\nodes;..\..\..\source\blender\blenpluginapi;..\..\..\source\blender\renderconverter;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\network;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\..\build\msvc_7\extern\verse\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\build\msvc_7\extern\glew\include"
                                PreprocessorDefinitions="_DEBUG;WIN32;_LIB;_CONSOLE;GAMEBLENDER;WITH_QUICKTIME;INTERNATIONAL;WITH_VERSE;WITH_OPENEXR;WITH_DDS;WITH_BULLET = 1;WITH_FFMPEG"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="1"
index 07fcfa64a72436a9d184ca28fd990fa0f9801551..7e2db4f564fbd99f9abfa38a84ad80f83a0c026f 100644 (file)
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_2DFilterActuator.cpp">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ActuatorEventManager.cpp">
+                       </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ActuatorSensor.cpp">
+                       </File>
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_AlwaysEventManager.cpp">
                        </File>
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_MouseSensor.cpp">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_NANDController.cpp">
+                       </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_NORController.cpp">
+                       </File>
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ORController.cpp">
                        </File>
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_TimeEventManager.cpp">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_XNORController.cpp">
+                       </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_XORController.cpp">
+                       </File>
                </Filter>
                <Filter
                        Name="Header Files"
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_2DFilterActuator.h">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ActuatorEventManager.h">
+                       </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ActuatorSensor.h">
+                       </File>
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_AlwaysEventManager.h">
                        </File>
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_MouseSensor.h">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_NANDController.h">
+                       </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_NORController.h">
+                       </File>
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ORController.h">
                        </File>
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_TimeEventManager.h">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_XNORController.h">
+                       </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_XORController.h">
+                       </File>
                </Filter>
        </Files>
        <Globals>
index af0ba74497a8829c1f9fc41dd6e40eea2f98d1cb..9d5a9f55074877e6aef998625fcd89a6d01b0e93 100644 (file)
                                <File
                                        RelativePath="..\..\..\source\gameengine\Ketsji\KX_SCA_AddObjectActuator.cpp">
                                </File>
+                               <File
+                                       RelativePath="..\..\..\source\gameengine\Ketsji\KX_SCA_DynamicActuator.cpp">
+                               </File>
                                <File
                                        RelativePath="..\..\..\source\gameengine\Ketsji\KX_SCA_EndObjectActuator.cpp">
                                </File>
                                <File
                                        RelativePath="..\..\..\source\gameengine\Ketsji\KX_SCA_AddObjectActuator.h">
                                </File>
+                               <File
+                                       RelativePath="..\..\..\source\gameengine\Ketsji\KX_SCA_DynamicActuator.h">
+                               </File>
                                <File
                                        RelativePath="..\..\..\source\gameengine\Ketsji\KX_SCA_EndObjectActuator.h">
                                </File>
index 31520b0654618e5fd383ed9b51d36e7d395092a1..9d55a7712fc77fdb813237d4bd321d935aa78ad6 100644 (file)
@@ -21,7 +21,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system"
+                               AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\..\lib\windows\python\include\python2.5"
                                PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_GLEXT"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="1"
                        <Tool
                                Name="VCCLCompilerTool"
                                InlineFunctionExpansion="1"
-                               AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system"
+                               AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\..\lib\windows\python\include\python2.5"
                                PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_GLEXT"
                                StringPooling="TRUE"
                                RuntimeLibrary="0"
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system"
+                               AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\..\lib\windows\python\include\python2.5"
                                PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_GLEXT"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="1"
                        <Tool
                                Name="VCCLCompilerTool"
                                InlineFunctionExpansion="1"
-                               AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system"
+                               AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\..\lib\windows\python\include\python2.5"
                                PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_GLEXT"
                                StringPooling="TRUE"
                                RuntimeLibrary="0"
index 130e93d8591d5d8760cf87cdc1e23108d4c94753..8a416c3c488112e9552453aa420da03edc55068a 100644 (file)
@@ -9,8 +9,8 @@ Fillename: 'Bake_Constraint.py'
 """
 
 __author__ = "Roger Wickes (rogerwickes(at)yahoo.com)"
-__script__ = "Bake Constraints"
-__version__ = "0.6"
+__script__ = "Animation Bake Constraints"
+__version__ = "0.7"
 __url__ = ["Communicate problems and errors, http://www.blenderartists.com/forum/private.php?do=newpm to PapaSmurf"]
 __email__= ["Roger Wickes, rogerwickes@yahoo.com", "scripts"]
 __bpydoc__ = """\
@@ -28,58 +28,62 @@ Developed for use with MoCap data, where a bone is constrained to point at an em
 moving through space and time. This records the actual locrot of the armature
 so that the motion can be edited, reoriented, scaled, and used as NLA Actions
 
-see also wiki Scripts/Manual/ Sandbox/Animation/Bake_Constraints (tbd)
+see also wiki Scripts/Manual/ Tutorial/Motion Capture <br>
 
-Usage:<br>
+Usage: <br>
  - Select the reference Object(s) you want to bake <br>
  - Set the frame range to bake in the Anim Panel <br>
  - Set the test code (if you want a self-test) in the RT field in the Anim Panel <br>
-               -- Set RT:1 in the Anim panel to create a test armature <br>
+       -- Set RT:1 to create a test armature <br>
+       -- Set RT: up to 100 for more debug messages and status updates <br>
 <br>
- - Run the script    <br>
- - The clone copy of the object is created and it has an IPO curve assigned to it. 
- - The clone shadows the object by an offset locrot (see usrDelta)
- - That Ipo has Location and Rotation curves that make the shadow mimic the movement of the selected object, 
-                but without using constraints. Bones move identically in relation to the armature as the reference object
+ - Run the script <br>
+ - The clone copy of the object is created and it has an IPO curve assigned to it. <br>
+ - The clone shadows the object by an offset locrot (see usrDelta) <br>
+ - That Object has Ipo Location and Rotation curves that make the clone mimic the movement <br>
+       of the selected object, but without using constraints. <br>
+ - If the object was an Armature, the clone's bones move identically in relation to the <br>
+       original armature, and an Action is created that drives the bone movements. <br>
 
-       
 Version History:
-               0.1: bakes Loc Rot for a constrained object
-               0.2: bakes Loc and Rot for the bones within Armature object
-               0.3: UI for setting options
-               0.3.1 add manual to script library
-               0.4: bake multiple objects
-               0.5: root bone worldspace rotation
-               0.6: re-integration with BPyArmature
-               
+       0.1: bakes Loc Rot for a constrained object
+       0.2: bakes Loc and Rot for the bones within Armature object
+       0.3: UI for setting options
+       0.3.1 add manual to script library
+       0.4: bake multiple objects
+       0.5: root bone worldspace rotation
+       0.6: re-integration with BPyArmature
+       0.7: bakes parents and leaves clones selected
+    
 License, Copyright, and Attribution:
-       by Roger WICKES  May 2008, released under Blender Artistic Licence to Public Domain
-               feel free to add to any Blender Python Scripts Bundle.
- Thanks to Jean-Baptiste PERIN, IdeasMan42 (Campbell Barton?), Basil_Fawlty/Cage_drei (Andrew Cruse)
+  by Roger WICKES  May 2008, released under Blender Artistic Licence to Public Domain
+    feel free to add to any Blender Python Scripts Bundle.
+ Thanks to Jean-Baptiste PERIN, IdeasMan42 (Campbell Barton), Basil_Fawlty/Cage_drei (Andrew Cruse)
  much lifted/learned from blender.org/documentation/245PytonDoc and wiki
  some modules based on c3D_Import.py, PoseLib16.py and IPO/Armature code examples e.g. camera jitter
 
-Pseudocode (planned versions):
+Pseudocode:
        Initialize
        If at least one object is selected
                For each selected object,
-                       create a shadow object
+                       create a cloned object
                        remove any constraints on the clone
                        create or reset an ipo curve named like the object
                        for each frame
                                 set the clone's locrot key based on the reference object
                        if it's an armature,
-                                       create an action (which is an Ipo for each bone)
-                                       for each frame of the animation
-                                               for each bone in the armature
-                                                       set the key
+                               create an action (which is an Ipo for each bone)
+                               for each frame of the animation
+                                       for each bone in the armature
+                                               set the key
        Else you're a smurf
 
 Test Conditions and Regressions:
        1. (v0.1) Non-armatures (the cube), with ipo curve and constraints at the object level
        2. armatures, with ipo curve and constraints at the object level
        3. armatures, with bones that have ipo curves and constraints
-       
+       4. objects without parents, children with unselected parents, select children first.
+  
 Naming conventions:
        arm = a specific objec type armature
        bone = bones that make up the skeleton of an armature
@@ -89,19 +93,6 @@ Naming conventions:
        pbone = pose bone, a posed bone in an object
        tst = testing, self-test routines
        usr = user-entered or designated stuff  
-
-Pattern Notes (let me know if I've violated any):
-       Bergin Starting,Designing, Programming, Coding
-       Bergin 23 Indent for Structure - I don't like only 2, but the editor is set up that way
-       Bergin 26 Be Spacey Not Tabby - personal frustraion here. workaround is to Format->convert to whitespace
-       Bergin 27 Consistent Capitalization - except Blender, because I love it.
-       Bergin 28 Name Your Constants - not for those I plan on making variable
-       Python 01 Return Everything - I made this one up, all functions and methods end in return
-               even though it is decoration in Python, it helps Python throw an indentation error for typing mistakes
-       Wickes 01 Decorate Your Code - for visual appeal and to ease maintenance, include separators like ######### 
-               to visually distinquish and separate functions, making it quicker to scan through code for methods
-       Wickes 02 Whitespace helps readability - include blanks around = # and lines (after def, after return) to make it stand out and pretty
-
 """
 ########################################
 
@@ -131,8 +122,8 @@ POSE_XFORM= [Blender.Object.Pose.LOC, Blender.Object.Pose.ROT]
 
 # set senstitivity for displaying debug/console messages. 0=none, 100=max
 # then call debug(num,string) to conditionally display status/info in console window
-MODE=Blender.Get('rt')  #execution mode: 0=run normal, x=self-test (test error trapping etc)
-DEBUG=100   #how much detail on internal processing for big brother to see
+MODE=Blender.Get('rt')  #execution mode: 0=run normal, 1=make test armature
+DEBUG=Blender.Get('rt')   #how much detail on internal processing for user to see. range 0-100
 BATCH=False #called from command line? is someone there? Would you like some cake?
 
 #there are two coordinate systems, the real, or absolute 3D space,
@@ -143,13 +134,11 @@ COORD_REAL = 1
 
 # User Settings - Change these options manually or via GUI (future TODO)
 usrCoord = COORD_REAL # what the user wants
-usrParent = False # True=keep parent (if exists), False = breakaway (usually with Real)
+usrParent = False # True=clone keeps original parent, False = clone's parent is the clone of the original parent (if cloned)
 usrFreeze = 2 #2=yes, 0=no. Freezes shadow object in place at current frame as origin
-       #TODO - i wonder if usrFreeze means we should set Delta to the the difference between the original object and parent?
 # delta is amount to offset/change from the reference object. future set in a ui, so technically not a constant
 usrDelta = [10,10,0,0,0,0] #order specific - Loc xyz Rot xyz
 usrACTION = True # Offset baked Action frames to start at frame 1
-usrBAKEobjIPO = False # bake the object Ipo? it is useless for MoCap, as we only want the Action, and the Object does not move
 
 CURFRAME = 'curframe' #keyword to use when getting the frame number that the scene is presently on
 ARMATURE = 'Armature' #en anglais
@@ -159,7 +148,7 @@ BONE_SPACES = ['ARMATURESPACE','BONESPACE']
 
 #Ipo curves created are prefixed with a name, like Ipo_ or Bake_ followed by the object/bone name
 #bakedArmName = "b." #used for both the armature class and object instance
-#ipoObjectNamePrefix= ""
+usrObjectNamePrefix= ""
 #ipoBoneNamePrefix  = ""
 # for example, if on entry an armature named Man was selected, and the object prefix was "a."
 #  on exit an armature and an IPO curve named a.Man exists for the object as a whole
@@ -177,7 +166,6 @@ scn = Blender.Scene.GetCurrent()
 #=================
 ########################################
 def debug(num,msg): #use log4j or just console here.
-       
        if DEBUG >= num:
                if BATCH == False:
                        print 'debug:             '[:num/10+7]+msg
@@ -201,9 +189,26 @@ def getRenderInfo():
        debug(90,'Scene is on frame %i and frame range is %i to %i' % (curframe,staframe,endframe))
        return (staframe,endframe,curframe)
 
+########################################
+def sortObjects(obs): #returns a list of objects sorted based on parent dependency
+       obClones= [] 
+       while len(obClones) < len(obs):
+               for ob in obs:
+                       if not ob in obClones:
+                               par= ob.getParent()
+                               #if no parent, or the parent is not scheduled to be cloned
+                               if par==None:
+                                       obClones.append(ob) # add the independent
+                               elif par not in obs: # parent will not be cloned
+                                       obClones.append(ob) # add the child
+                               elif par in obClones: # is it on the list?
+                                       obClones.append(ob) # add the child
+                               # parent may be a child, so it will be caught next time thru
+       debug(100,'clone object order: \n%s' % obClones)
+       return obClones # ordered list of (ob, par) tuples
+
 ########################################
 def sortBones(xbones): #returns a sorted list of bones that should be added,sorted based on parent dependency
-       print ('My suggestion would be:')
 #  while there are bones to add,
 #    look thru the list of bones we need to add
 #      if we have not already added this bone
@@ -215,7 +220,7 @@ def sortBones(xbones): #returns a sorted list of bones that should be added,sort
 #           else #we need to keep cycling and catch its parent
 #         else it is a root bone
 #           add it
-#       else skip it, it's prego
+#       else skip it, it's already in there
 #     endfor
 #  endwhile
        xboneNames=[]
@@ -240,7 +245,6 @@ def sortBones(xbones): #returns a sorted list of bones that should be added,sort
 
 ########################################
 def dupliArmature(ob): #makes a copy in current scn of the armature used by ob and its bones
-       
        ob_mat = ob.matrixWorld
        ob_data = ob.getData()
        debug(49,'Reference object uses %s' % ob_data)
@@ -261,8 +265,6 @@ def dupliArmature(ob): #makes a copy in current scn of the armature used by ob a
        #when creating a child, we cannot link to a parent if it does not yet exist in our armature 
        ebones = [] #list of the bones I want to create for my arm
 
-       if BLENDER_VERSION > 245: debug(0,'WARNING: Programmer check for Bone updates in dupliArmature')
-
        eboneNames = sortBones(xbones)
 
        i=0
@@ -306,13 +308,13 @@ def dupliArmature(ob): #makes a copy in current scn of the armature used by ob a
        print myob.matrix
        
        return myob
-
+########################################
 def scrub(): # scrubs to startframe
        staFrame,endFrame,curFrame = getRenderInfo()
 
        # eye-candy, go from current to start, fwd or back
        if not BATCH:
-               print "Positioning to start..."
+               debug(100, "Positioning to start...")
                frameinc=(staFrame-curFrame)/10
                if abs(frameinc) >= 1:
                        for i in range(10):
@@ -320,6 +322,7 @@ def scrub(): # scrubs to startframe
                                Blender.Set(CURFRAME,curFrame) # computes the constrained location of the 'real' objects
                                Blender.Redraw()
        Blender.Set(CURFRAME, staFrame)
+       return
 
 ########################################
 def bakeBones(ref_ob,arm_ob): #copy pose from ref_ob to arm_ob
@@ -335,7 +338,6 @@ def bakeBones(ref_ob,arm_ob): #copy pose from ref_ob to arm_ob
        arm_channels = act.getAllChannelIpos()
        pose= arm_ob.getPose()
        pbones= pose.bones.values() #we want the bones themselves, not the dictionary lookup
-       print arm_channels.keys()
        for pbone in pbones:
                debug (100,'Channel listing for %s: %s' % (pbone.name,arm_channels[pbone.name] ))
                ipo=arm_channels[pbone.name]
@@ -344,8 +346,7 @@ def bakeBones(ref_ob,arm_ob): #copy pose from ref_ob to arm_ob
        return
 
 ########################################
-def getOrCreateCurve(ipo, curvename): 
-       
+def getOrCreateCurve(ipo, curvename):
        """
        Retrieve or create a Blender Ipo Curve named C{curvename} in the C{ipo} Ipo
        Either an ipo curve named C{curvename} exists before the call then this curve is returned,
@@ -362,18 +363,17 @@ def getOrCreateCurve(ipo, curvename):
        return mycurve
 
 ########################################
-def eraseCurve(ipo,numCurves): 
-       debug(80,'Erasing %i curves for %' % (numCurves,ipo.GetName()))
+def eraseCurve(ipo,numCurves):
+       debug(90,'Erasing %i curves for %' % (numCurves,ipo.GetName()))
        for i in range(numCurves):
-               nbBezPoints = ipo.getNBezPoints(i)
+               nbBezPoints= ipo.getNBezPoints(i)
                for j in range(nbBezPoints):
                        ipo.delBezPoint(i)
        return
 
 ########################################
 def resetIPO(ipo):
-       ipoName=ipoObjectNamePrefix + obName
-       debug(40,'Resetting ipo curve named %s' %ipoName)
+       debug(60,'Resetting ipo curve named %s' %ipo.name)
        numCurves = ipo.getNcurves() #like LocX, LocY, etc
        if numCurves > 0:
                eraseCurve(ipo, numCurves) #erase data if one exists
@@ -399,11 +399,11 @@ def resetIPOs(ob): #resets all IPO curvess assocated with an object and its bone
        return
 
 ########################################
-def parse(string,delim):       
+def parse(string,delim):
        index = string.find(delim) # -1 if not found, else pointer to delim
        if index+1:  return string[:index]
        return string
-               
+
 ########################################
 def newIpo(ipoName): #add a new Ipo object to the Blender scene
        ipo=Blender.Ipo.New('Object',ipoName)
@@ -438,19 +438,16 @@ def makeUpaName(type,name): #i know this exists in Blender somewhere...
                name=ipoName 
        else:
                debug (0,'FATAL ERROR: I dont know how to make up a new %s name based on %s' % (type,ob))
-               return 
+               return None
        return name
 
 ########################################
-def createIpo(ob): #create an Ipo and curves and link them to this object      
+def createIpo(ob): #create an Ipo and curves and link them to this object
        #first, we have to create a unique name
        #try first with just the name of the object to keep things simple.
        ipoName = makeUpaName('Ipo',ob.getName()) # make up a name for a new Ipo based on the object name
-
        debug(20,'Ipo and LocRot curves called %s' % ipoName)
-
        ipo=newIpo(ipoName)
-
        ob.setIpo(ipo) #link them
        return ipo
 
@@ -465,7 +462,7 @@ def getLocLocal(ob):
                        ob.RotZ*R2D
                        ]
        return key
-                               
+
 ########################################
 def getLocReal(ob):
        obMatrix = ob.matrixWorld #Thank you IdeasMan42
@@ -505,7 +502,7 @@ def getCurves(ipo):
                        ipo[Ipo.OB_ROTZ]
                        ]
        return ipos
-                                       
+
 ########################################
 def addPoint(time,keyLocRot,ipos):
        if BLENDER_VERSION < 245:
@@ -579,7 +576,7 @@ def removeConstraints(ob):
                debug(90,'removed %s => %s' % (ob.name, const))
                ob.constraints.remove(const)
        return
-               
+    
 ########################################
 def removeConstraintsOb(ob): # from object or armature
        debug(40,'Removing constraints from '+ob.getName())
@@ -605,37 +602,27 @@ def bakeObject(ob): #bakes the core object locrot and assigns the Ipo to a Clone
        if ob != None:  
                # Clone the object - duplicate it, clean the clone, and create an ipo curve for the clone
                myob = duplicateLinked(ob)  #clone it
+               myob.name= usrObjectNamePrefix + ob.getName()
                removeConstraintsOb(myob)   #my object is a free man
                deLinkOb('Ipo',myob)        #kids, it's not nice to share. you've been lied to
-               if usrBAKEobjIPO:
+               if ob.getType() != ARMATURE: # baking armatures is based on bones, not object
                        myipo = createIpo(myob)     #create own IPO and curves for the clone object
                        ipos = bakeFrames(ob,myipo) #bake the locrot for this obj for the scene frames
-
-#  staframe,endframe,curframe = getRenderInfo()
-#  frame = staframe
-#  Blender.Set(CURFRAME,frame) # computes the constrained location of the 'real' objects
-#  frame +=1
-#  Blender.Set(CURFRAME,frame) # computes the constrained location of the 'real' objects
-#  frame -=1
-#  Blender.Set(CURFRAME,frame) # computes the constrained location of the 'real' objects
-#  if not BATCH: Blender.Redraw()
-#
        return myob
-               
-########################################
-def bake(ob): #bakes an object of any type
-       
-       debug(30,'Baking %s object %s' % (ob.getType(), ob))
-
-       myob = bakeObject(ob) #creates and bakes the object motion
-
+    
+########################################
+def bake(ob,par): #bakes an object of any type, linking it to parent
+       debug(0,'Baking %s object %s' % (ob.getType(), ob))
+       clone = bakeObject(ob) #creates and bakes the object motion
+       if par!= None:
+               par.makeParent([clone])  
+               debug(20,"assigned object to parent %s" % par)
        if ob.getType() == ARMATURE:
-#      error('Object baked. Continue with bones?')
-                       bakeBones(ob,myob) #go into the bones and copy from -> to in frame range
+##              error('Object baked. Continue with bones?')
+               bakeBones(ob,clone) #go into the bones and copy from -> to in frame range
        #future idea: bakeMesh (net result of Shapekeys, Softbody, Cloth, Fluidsim,...)
-                               
-       return
-               
+       return clone
+    
 ########################################
 def tstCreateArm(): #create a test armature in scene
        # rip-off from http://www.blender.org/documentation/245PythonDoc/Pose-module.html - thank you!
@@ -690,8 +677,8 @@ def tstCreateArm(): #create a test armature in scene
 
        frame = 1
        for pbone in pbones: # set bones to no rotation
-                                       pbone.quat[:] = 1.000,0.000,0.000,0.0000
-                                       pbone.insertKey(arm_ob, frame, Object.Pose.ROT)
+               pbone.quat[:] = 1.000,0.000,0.000,0.0000
+               pbone.insertKey(arm_ob, frame, Object.Pose.ROT)
 
        # Set a different rotation at frame 25
        pbones[0].quat[:] = 1.000,0.1000,0.2000,0.20000
@@ -747,7 +734,7 @@ def tstMoveOb(ob): # makes a simple LocRot animation of object in the scene
 
                debug(100,'%s %i %.3f %.2f %.2f %.2f %.2f %.2f %.2f' % (ipo.name, frame, time, key[0], key[1], key[2], key[3], key[4], key[5]))
                frame += frameDelta
-       Blender.Set('curframe',curframe) # reset back to where we started
+       Blender.Set(CURFRAME,curframe) # reset back to where we started
        return
 #=================
 # Program Template
@@ -755,25 +742,31 @@ def tstMoveOb(ob): # makes a simple LocRot animation of object in the scene
 ########################################
 def main():
        # return code set via rt button in Blender Buttons Scene Context Anim panel
-       
        if MODE == 1: #create test armature #1
                ob = tstCreateArm()      # make test arm and select it
                tstMoveOb(ob)
                scn.objects.selected = [ob]
 
-       obs = Blender.Object.GetSelected() #scn.objects.selected
-       debug(20,'Baking %i objects' % len(obs))
+       obs= Blender.Object.GetSelected() #scn.objects.selected
+       obs= sortObjects(obs)
+       debug(0,'Baking %i objects' % len(obs))
 
        if len(obs) >= 1:   # user might have multiple objects selected
+               i= 0
+               clones=[] # my clone army
                for ob in obs:
-                       bake(ob)
+                       par= ob.getParent()
+                       if not usrParent:
+                               if par in obs:
+                                       par= clones[obs.index(par)]
+                       clones.append(bake(ob,par))
+               scn.objects.selected = clones
        else:
                error('Please select at least one object')
        return
 
 ########################################
 def benchmark(): # This lets you benchmark (time) the script's running duration 
-       
        Window.WaitCursor(1) 
        t = sys.time() 
        debug(60,'%s began at %.0f' %(__script__,sys.time()))
@@ -787,7 +780,7 @@ def benchmark(): # This lets you benchmark (time) the script's running duration
        if in_editmode: Window.EditMode(1)
        
        # Timing the script is a good way to be aware on any speed hits when scripting 
-       debug(60,'%s Script finished in %.2f seconds' % (__script__,sys.time()-t) )
+       debug(0,'%s Script finished in %.2f seconds' % (__script__,sys.time()-t) )
        Window.WaitCursor(0) 
        return
 
@@ -795,6 +788,5 @@ def benchmark(): # This lets you benchmark (time) the script's running duration
 # This lets you can import the script without running it 
 if __name__ == '__main__': 
        debug(0, "------------------------------------")
-       debug(0, '%s %s Script begins with mode=%i debug=%i batch=%s version=%i' % (__script__,__version__,MODE,DEBUG,BATCH,BLENDER_VERSION))
-
+       debug(0, "%s %s Script begins with mode=%i debug=%i batch=%s" % (__script__,__version__,MODE,DEBUG,BATCH))
        benchmark()
index d67d56261d120fa0cf6cd04ee8d18c7e0784b0f9..ca4f8cd79e90e12e21cf0611a03db5ae11e4696e 100644 (file)
@@ -8,7 +8,7 @@ Tooltip: 'Import a C3D Motion Capture file'
 """
 __script__ = "C3D Motion Capture file import"
 __author__ = " Jean-Baptiste PERIN, Roger D. Wickes (rogerwickes@yahoo.com)"
-__version__ = "0.8"
+__version__ = "0.9"
 __url__ = ["Communicate problems and errors, BlenderArtists.org, Python forum"]
 __email__= ["rogerwickes@yahoo.com", "c3d script"]
 __bpydoc__ = """\
@@ -16,9 +16,9 @@ c3d_import.py v0.8
 
 Script loading Graphics Lab Motion Capture file,  
 Usage:<br>
- - Run the script <br>
- - Choose the file to open<br>
- - Press Import C3D button<br>
      - Run the script <br>
      - Choose the file to open<br>
      - Press Import C3D button<br>
 
 Version History:
  0.4: PERIN Released under Blender Artistic Licence
@@ -26,6 +26,7 @@ Version History:
  0.6: WICKES creates armature for each subject
  0.7: WICKES constrains armature to follow the empties (markers). Verified for shake hands s
  0.8: WICKES resolved DEC support issue
+ 0.9: BARTON removed scene name change, whitespace edits. WICKES added IK layers
 """
 
 #----------------------------------------------
@@ -69,12 +70,12 @@ XYZ_LIMIT= 10000 #max value for coordinates if in integer format
 # selecting only layer 2 shows only the armature moving, 12 shows only the empties
 LAYERS_ARMOB= [1,2]
 LAYERS_MARKER=[1,12]
+LAYERS_IK=[1,11]
+IK_PREFIX="ik_" # prefix in empty name: ik_prefix+subject prefix+bone name
+
 CLEAN=True # Should program ignore markers at (0,0,0) and beyond the outer limits?
 
 scn = Blender.Scene.GetCurrent()
-# Why on earth would you rename a scene when importing data??? - Campbell
-# scn.name="MoCap" #may want this enterable or derived based on motion being analyzed
-#TODO: ultimately, a library of motions to append from means you need good naming of things
 
 BCS=Blender.Constraint.Settings # shorthand dictionary - define with brace, reference with bracket
 trackto={"+x":BCS.TRACKX, "+y":BCS.TRACKY, "+z":BCS.TRACKZ, "-x":BCS.TRACKNEGX, "-y":BCS.TRACKNEGY, "-z":BCS.TRACKNEGZ}
@@ -169,22 +170,21 @@ def getEmpty(name):
 # in  : objname : le nom de l'empty recherche
 # out : myobj : l'empty cree ou retrouve
 #########
-def GetOrCreateEmpty(objname):
+def getOrCreateEmpty(objname):
        myobj= getEmpty(objname)
        if myobj==None: 
                myobj = scn.objects.new("Empty",objname)
-               myobj.layers= LAYERS_MARKER
                debug(50,'Marker/Empty created %s' %  myobj)
        return myobj
 
-def GetOrCreateCurve(ipo, curvename):
+def getOrCreateCurve(ipo, curvename):
        """
        Retrieve or create a Blender Ipo Curve named C{curvename} in the C{ipo} Ipo
 
        >>> import mylib 
 
        >>> lIpo = GetOrCreateIPO("Une IPO")
-       >>> laCurve = GetOrCreateCurve(lIpo, "RotX")
+       >>> laCurve = getOrCreateCurve(lIpo, "RotX")
 
        Either an ipo curve named C{curvename} exists before the call then this curve is returned,
        Or such a curve doesn't exist before the call .. then it is created into the c{ipo} Ipo and returned 
@@ -338,7 +338,8 @@ def makeNodes(prefix, markerList, empties, marker_set): #make sure the file has
                        elif usrOption==1: #add these markers as static empties, and user will automate them later
                                #and the bones will be keyed to them, so it will all be good.
                                #file may have just mis-named the empty, or the location can be derived based on other markers
-                               em= GetOrCreateEmpty(err[2])
+                               em= getOrCreateEmpty(err[2])
+                               em.layers= LAYERS_MARKER
                        else: abort() #abend
                        if DEBUG==100: status("Nodes Updated")
        return nodes #nodes may be updated
@@ -411,8 +412,9 @@ def makeConstIK(prefix,pbone,const):
        #Blender 246 only supports one IK Solver per bone, but we might want many,
        #  so we need to create a reference empty named after the bone
        #  that floats between the markers, so the bone can point to it as a singularity
-       myob= GetOrCreateEmpty(prefix+pbone.name)
-       # note that this empty gets all the IK constraints added on
+       myob= getOrCreateEmpty(IK_PREFIX+prefix+pbone.name)
+       myob.layers= LAYERS_IK
+       # note that this empty gets all the IK constraints added on as location constraints
        myconst= myob.constraints.append(Constraint.Type.COPYLOC)
        myconst.name=const[0]+"-"+const[1]
        myconst[Constraint.Settings.TARGET]= Blender.Object.Get(const[1])
@@ -438,15 +440,18 @@ def makeConstTT(pbone,const):
        myconst= pbone.constraints.append(Constraint.Type.TRACKTO)
        myconst.name=const[0]+"-"+const[1]
        debug(70,"%s %s" % (myconst,const[3]))
-       myob= GetOrCreateEmpty(const[1])
-       myconst[BCS.TARGET]= myob
-       myconst.influence = const[2]
-       #const[3] is the Track and the thrird char is the Up indicator
-       myconst[BCS.TRACK]= trackto[const[3][0:2].lower()]
-       myconst[BCS.UP]=trackup[const[3][2].lower()]#up direction
-       myconst[BCS.OWNERSPACE]= BCS.SPACE_LOCAL
-       myconst[BCS.TARGETSPACE]= [BCS.SPACE_LOCAL]
-       if const[3][1]==const[3][2]: debug(0,"WARNING: Track To axis and up axis should not be the same. Constraint is INACTIVE")
+       myob= getEmpty(const[1])
+       if myob!= None:
+               myconst[BCS.TARGET]= myob
+               myconst.influence = const[2]
+               #const[3] is the Track and the thrird char is the Up indicator
+               myconst[BCS.TRACK]= trackto[const[3][0:2].lower()]
+               myconst[BCS.UP]=trackup[const[3][2].lower()]#up direction
+               myconst[BCS.OWNERSPACE]= BCS.SPACE_LOCAL
+               myconst[BCS.TARGETSPACE]= [BCS.SPACE_LOCAL]
+               if const[3][1]==const[3][2]: debug(0,"WARNING: Track To axis and up axis should not be the same. Constraint is INACTIVE")
+       else:   #marker not found. could be missing from this file, or an error in node spec
+               error("TrackTo Constraint for %s |specifies unknown marker %s" % (pbone.name,const[1]))
        return
 
 def makePoses(prefix,arm_ob,nodes): # pose this armature object based on node requirements
@@ -543,15 +548,16 @@ def makeCloud(Nmarkers,markerList,StartFrame,EndFrame,Markers):
        for i in range(Nmarkers):
                debug(100,"%i marker %s"%(i, markerList[i]))
                emptyname = markerList[i] # rdw: to use meaningful names from Points parameter
-               em= GetOrCreateEmpty(emptyname) #in this scene
+               em= getOrCreateEmpty(emptyname) #in this scene
+               em.layers= LAYERS_MARKER
                #make a list of the actual empty
                empties.append(em)
                #assign it an ipo with the loc xyz curves
                lipo = Ipo.New("Object",em.name)
                ipos.append(lipo)
-               curvesX.append(GetOrCreateCurve(ipos[i],'LocX'))
-               curvesY.append(GetOrCreateCurve(ipos[i],'LocY'))
-               curvesZ.append(GetOrCreateCurve(ipos[i],'LocZ'))
+               curvesX.append(getOrCreateCurve(ipos[i],'LocX'))
+               curvesY.append(getOrCreateCurve(ipos[i],'LocY'))
+               curvesZ.append(getOrCreateCurve(ipos[i],'LocZ'))
                empties[i].setIpo(ipos[i])
        debug(30,"Cloud of %i empties created." % len(empties))
        NvideoFrames= EndFrame-StartFrame+1
index 338075c1b18e64bd6fa7e1b333d07b11edc99b69..c96b188fb0287ce6426dcc71551d7bc1f38520a9 100644 (file)
@@ -353,6 +353,7 @@ Section "Blender-VERSION (required)" SecCopyUI
   SetOutPath $INSTDIR
   ; Write the installation path into the registry
   WriteRegStr HKLM SOFTWARE\BlenderFoundation "Install_Dir" "$INSTDIR"
+  WriteRegStr HKLM SOFTWARE\BlenderFoundation "Home_Dir" "$BLENDERHOME"
   ; Write the uninstall keys for Windows
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayName" "Blender (remove only)"
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "UninstallString" '"$INSTDIR\uninstall.exe"'
@@ -406,28 +407,32 @@ SectionEnd
 UninstallText "This will uninstall Blender VERSION. Hit next to continue."
 
 Section "Uninstall"
+  Delete $INSTDIR\uninstall.exe
+  
+  ReadRegStr $BLENDERHOME HKLM "SOFTWARE\BlenderFoundation" "Home_Dir"
+  
   ; remove registry keys
   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender"
   DeleteRegKey HKLM SOFTWARE\BlenderFoundation
   ; remove files
   [DELROOTDIRCONTS]
   
-  Delete $INSTDIR\.blender\.bfont.ttf
-  Delete $INSTDIR\.blender\.Blanguages
+  Delete $BLENDERHOME\.blender\.bfont.ttf
+  Delete $BLENDERHOME\.blender\.Blanguages
   ; remove shortcuts, if any.
   Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*"
   Delete "$DESKTOP\Blender.lnk"
   ; remove directories used.
-  RMDir /r $INSTDIR\.blender\locale
+  RMDir /r $BLENDERHOME\.blender\locale
   MessageBox MB_YESNO "Erase .blender\scripts folder? (ALL contents will be erased!)" IDNO Next
-  RMDir /r $INSTDIR\.blender\scripts
-  RMDir /r $INSTDIR\.blender\scripts\bpymodules
-  RMDir /r $INSTDIR\.blender\scripts\bpydata
-  RMDir /r $INSTDIR\.blender\scripts\bpydata\config
+  RMDir /r $BLENDERHOME\.blender\scripts
+  RMDir /r $BLENDERHOME\.blender\scripts\bpymodules
+  RMDir /r $BLENDERHOME\.blender\scripts\bpydata
+  RMDir /r $BLENDERHOME\.blender\scripts\bpydata\config
 Next:
-  RMDir /r $INSTDIR\plugins\include
-  RMDir /r $INSTDIR\plugins
-  RMDir $INSTDIR\.blender
+  RMDir /r $BLENDERHOME\plugins\include
+  RMDir /r $BLENDERHOME\plugins
+  RMDir $BLENDERHOME\.blender
   RMDir "$SMPROGRAMS\Blender Foundation\Blender"
   RMDir "$SMPROGRAMS\Blender Foundation"
   RMDir "$INSTDIR"
index 51a5d29dbb74a338263581257df56f7ba8ae54e9..8ec7144faf6658ff9cfe507796402bf2b357d7c0 100644 (file)
 
 #include "DNA_listBase.h"
 #include "BLI_ghash.h"
+#include "BLI_mempool.h"
 #include "BLI_memarena.h"
 #include "DNA_image_types.h"
 #include "BLI_editVert.h"
 #include "BKE_DerivedMesh.h"
 #include "transform.h"
-#include "BKE_bmeshCustomData.h"
 
 /*forward declerations*/
 struct BME_Vert;
@@ -53,13 +53,6 @@ struct BME_Poly;
 struct BME_Loop;
 
 
-/*structure for fast memory allocation/frees*/
-typedef struct BME_mempool{
-       struct ListBase chunks;
-       int esize, csize, pchunk;               /*size of elements and chunks in bytes and number of elements per chunk*/
-       struct BME_freenode     *free;          /*free element list. Interleaved into chunk datas.*/
-}BME_mempool;
-
 /*Notes on further structure Cleanup:
        -Remove the tflags, they belong in custom data layers
        -Remove the eflags completely, they are mostly not used
@@ -78,10 +71,10 @@ typedef struct BME_Mesh
 {
        ListBase verts, edges, polys;
        /*memory pools used for storing mesh elements*/
-       struct BME_mempool *vpool;
-       struct BME_mempool *epool;
-       struct BME_mempool *ppool;
-       struct BME_mempool *lpool;
+       struct BLI_mempool *vpool;
+       struct BLI_mempool *epool;
+       struct BLI_mempool *ppool;
+       struct BLI_mempool *lpool;
        /*some scratch arrays used by eulers*/
        struct BME_Vert **vtar;
        struct BME_Edge **edar;
@@ -90,7 +83,7 @@ typedef struct BME_Mesh
        int vtarlen, edarlen, lparlen, plarlen;
        int totvert, totedge, totpoly, totloop;                         /*record keeping*/
        int nextv, nexte, nextp, nextl;                                         /*Next element ID for verts/edges/faces/loops. Never reused*/
-       struct BME_CustomData vdata, edata, pdata, ldata;       /*Custom Data Layer information*/
+       struct CustomData vdata, edata, pdata, ldata;   /*Custom Data Layer information*/
 } BME_Mesh;
 
 typedef struct BME_Vert
@@ -169,7 +162,7 @@ int BME_radial_find_face(struct BME_Edge *e,struct BME_Poly *f);
 struct BME_Loop *BME_loop_find_loop(struct BME_Poly *f, struct BME_Vert *v);
 
 /*MESH CREATION/DESTRUCTION*/
-struct BME_Mesh *BME_make_mesh(int allocsize[4], struct BME_CustomDataInit init[4]);
+struct BME_Mesh *BME_make_mesh(int allocsize[4]);
 void BME_free_mesh(struct BME_Mesh *bm);
 /*FULL MESH VALIDATION*/
 int BME_validate_mesh(struct BME_Mesh *bm, int halt);
index 423f75e532d582d84003f8e5a94e5288dc0f4571..4f5f2641f548d72596b136ab23048c03d10b5e6f 100644 (file)
@@ -38,7 +38,7 @@
 #ifndef BKE_BMESHCUSTOMDATA_H
 #define BKE_BMESHCUSTOMDATA_H
 
-struct BME_mempool;
+struct BLI_mempool;
 
 /*Custom Data Types and defines
        Eventual plan is to move almost everything to custom data and let caller
@@ -62,7 +62,7 @@ typedef struct BME_CustomDataLayer {
 
 typedef struct BME_CustomData {
        struct BME_CustomDataLayer *layers;     /*Custom Data Layers*/
-       struct BME_mempool *pool;                               /*pool for alloc of blocks*/
+       struct BLI_mempool *pool;                               /*pool for alloc of blocks*/
        int totlayer, totsize;          /*total layers and total size in bytes of each block*/
 } BME_CustomData;
 
index 2e5da236a897190ed4fc0230faed73c4dfd2766a..f3c13d3d82051cf52924a6dcdd4ce77169cdb4ae 100644 (file)
@@ -208,7 +208,7 @@ typedef enum
 ////////////////////////////////////////////////
 
 // needed for implicit.c
-int cloth_bvh_objcollision ( ClothModifierData * clmd, float step, float dt );
+int cloth_bvh_objcollision ( Object *ob, ClothModifierData * clmd, float step, float dt );
 
 ////////////////////////////////////////////////
 
index d0535f1752eb5d9b62cec6c4057de1b884d43ff2..e84c7d309566238be4b97cc1cbcff489e67538e0 100644 (file)
@@ -40,6 +40,8 @@ extern const CustomDataMask CD_MASK_BAREMESH;
 extern const CustomDataMask CD_MASK_MESH;
 extern const CustomDataMask CD_MASK_EDITMESH;
 extern const CustomDataMask CD_MASK_DERIVEDMESH;
+extern const CustomDataMask CD_MASK_BMESH;
+extern const CustomDataMask CD_MASK_FACECORNERS;
 
 /* for ORIGINDEX layer type, indicates no original index for this element */
 #define ORIGINDEX_NONE -1
@@ -134,6 +136,9 @@ void CustomData_copy_data(const struct CustomData *source,
 void CustomData_em_copy_data(const struct CustomData *source,
                             struct CustomData *dest, void *src_block,
                             void **dest_block);
+void CustomData_bmesh_copy_data(const struct CustomData *source, 
+                                                       struct CustomData *dest,void *src_block, 
+                                                       void **dest_block);
 
 /* frees data in a CustomData object
  * return 1 on success, 0 on failure
@@ -160,6 +165,10 @@ void CustomData_interp(const struct CustomData *source, struct CustomData *dest,
 void CustomData_em_interp(struct CustomData *data,  void **src_blocks,
                           float *weights, float *sub_weights, int count,
                           void *dest_block);
+void CustomData_bmesh_interp(struct CustomData *data, void **src_blocks, 
+                                                        float *weights, float *sub_weights, int count, 
+                                                        void *dest_block);
+
 
 /* swaps the data in the element corners, to new corners with indices as
    specified in corner_indices. for edges this is an array of length 2, for
@@ -172,6 +181,8 @@ void CustomData_swap(struct CustomData *data, int index, int *corner_indices);
 void *CustomData_get(const struct CustomData *data, int index, int type);
 void *CustomData_em_get(const struct CustomData *data, void *block, int type);
 void *CustomData_em_get_n(const struct CustomData *data, void *block, int type, int n);
+void *CustomData_bmesh_get(const struct CustomData *data, void *block, int type);
+void *CustomData_bmesh_get_n(const struct CustomData *data, void *block, int type, int n);
 
 /* gets a pointer to the active or first layer of type
  * returns NULL if there is no layer of type
@@ -199,6 +210,12 @@ void CustomData_em_set(struct CustomData *data, void *block, int type,
 void CustomData_em_set_n(struct CustomData *data, void *block, int type, int n,
                          void *source);
 
+void CustomData_bmesh_set(const struct CustomData *data, void *block, int type, 
+                                                 void *source);
+
+void CustomData_bmesh_set_n(struct CustomData *data, void *block, int type, int n, 
+                                                       void *source);
+
 /* set the pointer of to the first layer of type. the old data is not freed.
  * returns the value of ptr if the layer is found, NULL otherwise
  */
@@ -220,12 +237,20 @@ void CustomData_set_layer_flag(struct CustomData *data, int type, int flag);
 void CustomData_em_set_default(struct CustomData *data, void **block);
 void CustomData_em_free_block(struct CustomData *data, void **block);
 
+void CustomData_bmesh_set_default(struct CustomData *data, void **block);
+void CustomData_bmesh_free_block(struct CustomData *data, void **block);
+
 /* copy custom data to/from layers as in mesh/derivedmesh, to editmesh
    blocks of data. the CustomData's must not be compatible  */
 void CustomData_to_em_block(const struct CustomData *source,
                             struct CustomData *dest, int index, void **block);
 void CustomData_from_em_block(const struct CustomData *source,
                               struct CustomData *dest, void *block, int index);
+void CustomData_to_bmesh_block(const struct CustomData *source, 
+                                                       struct CustomData *dest, int src_index, void **dest_block);
+void CustomData_from_bmesh_block(const struct CustomData *source, 
+                                                       struct CustomData *dest, void *src_block, int dest_index);
+
 
 /* query info over types */
 void CustomData_file_write_info(int type, char **structname, int *structnum);
@@ -241,4 +266,8 @@ void CustomData_set_layer_unique_name(struct CustomData *data, int index);
    only after this test passes, layer->data should be assigned */
 int CustomData_verify_versions(struct CustomData *data, int index);
 
+/*BMesh specific customdata stuff*/
+void CustomData_to_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata);
+void CustomData_from_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata, int total);
+void CustomData_bmesh_init_pool(struct CustomData *data, int allocsize);
 #endif
index 922f320134578b1bb39225bb6b49e4330ded83ae..5b209cb8f5b80838d71f4a486618936271e76f05 100644 (file)
 #ifndef BKE_IPO_H
 #define BKE_IPO_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct CfraElem {
        struct CfraElem *next, *prev;
        float cfra;
@@ -111,5 +115,9 @@ float IPO_GetFloatValue(struct Ipo *ipo,
                                                short c,
                                                float ctime);
 
+#ifdef __cplusplus
+};
+#endif
+
 #endif
 
index 8b48efbdbd23b740fe49625a410a23aaa01db372..1fc8a4071dc8bf6b760e60e4b084ad367408fb34 100644 (file)
@@ -40,6 +40,7 @@
 #include "bmesh_private.h"
 #include <string.h>
 #include "MEM_guardedalloc.h"
+#include "BLI_mempool.h"
 
 /********************* Layer type information **********************/
 typedef struct BME_LayerTypeInfo {
@@ -83,7 +84,7 @@ void BME_CD_Create(BME_CustomData *data, BME_CustomDataInit *init, int initalloc
        if(data->totlayer){
                /*alloc memory*/
                data->layers = MEM_callocN(sizeof(BME_CustomDataLayer)*data->totlayer, "BMesh Custom Data Layers");
-               data->pool = BME_mempool_create(data->totsize, initalloc, initalloc);
+               data->pool = BLI_mempool_create(data->totsize, initalloc, initalloc);
                /*initialize layer data*/
                for(i=0; i < BME_CD_NUMTYPES; i++){
                        if(init->layout[i]){
@@ -102,7 +103,7 @@ void BME_CD_Create(BME_CustomData *data, BME_CustomDataInit *init, int initalloc
 
 void BME_CD_Free(BME_CustomData *data)
 {
-       if(data->pool) BME_mempool_destroy(data->pool);
+       if(data->pool) BLI_mempool_destroy(data->pool);
 }
 
 /*Block level ops*/
@@ -119,7 +120,7 @@ void BME_CD_free_block(BME_CustomData *data, void **block)
                        typeInfo->free((char*)*block + offset, 1, typeInfo->size);
                }
        }
-       BME_mempool_free(data->pool, *block);
+       BLI_mempool_free(data->pool, *block);
        *block = NULL;
 }
 
@@ -130,7 +131,7 @@ static void BME_CD_alloc_block(BME_CustomData *data, void **block)
        if (*block) BME_CD_free_block(data, block); //if we copy layers that have their own free functions like deformverts
        
        if (data->totsize > 0)
-               *block = BME_mempool_alloc(data->pool); 
+               *block = BLI_mempool_alloc(data->pool); 
        else
                *block = NULL;
 }
index 08483711c45bf95adeddc120e050f3ed4c5979ef..daf0de5b748e1e91eafe368dbc0f0909c648ace6 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include "MEM_guardedalloc.h"
+#include "BKE_customdata.h" 
 
 #include "DNA_listBase.h"
 #include "DNA_meshdata_types.h"
 
 #include "BSE_edit.h"
 
+/*merge these functions*/
+static void BME_DMcorners_to_loops(BME_Mesh *bm, CustomData *facedata, int index, BME_Poly *f, int numCol, int numTex){
+       int i, j;
+       BME_Loop *l;
+       MTFace *texface;
+       MTexPoly *texpoly;
+       MCol *mcol;
+       MLoopCol *mloopcol;
+       MLoopUV *mloopuv;
+
+       for(i=0; i< numTex; i++){
+               texface = CustomData_get_layer_n(facedata, CD_MTFACE, i);
+               texpoly = CustomData_bmesh_get_n(&bm->pdata, f->data, CD_MTEXPOLY, i);
+
+               texpoly->tpage = texface[index].tpage;
+               texpoly->flag = texface[index].flag;
+               texpoly->transp = texface[index].transp;
+               texpoly->mode = texface[index].mode;
+               texpoly->tile = texface[index].tile;
+               texpoly->unwrap = texface[index].unwrap;
+
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPUV, i);
+                       mloopuv->uv[0] = texface[index].uv[j][0];
+                       mloopuv->uv[1] = texface[index].uv[j][1];
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+       }
+
+       for(i=0; i < numCol; i++){
+               mcol = CustomData_get_layer_n(facedata, CD_MCOL, i);
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPCOL, i);
+                       mloopcol->r = mcol[(index*4)+j].r;
+                       mloopcol->g = mcol[(index*4)+j].g;
+                       mloopcol->b = mcol[(index*4)+j].b;
+                       mloopcol->a = mcol[(index*4)+j].a;
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+       }
+}
+
+static void BME_DMloops_to_corners(BME_Mesh *bm, CustomData *facedata, int index, BME_Poly *f,int numCol, int numTex){
+       int i, j;
+       BME_Loop *l;
+       MTFace *texface;
+       MTexPoly *texpoly;
+       MCol *mcol;
+       MLoopCol *mloopcol;
+       MLoopUV *mloopuv;
+
+       for(i=0; i < numTex; i++){
+               texface = CustomData_get_layer_n(facedata, CD_MTFACE, i);
+               texpoly = CustomData_bmesh_get_n(&bm->pdata, f->data, CD_MTEXPOLY, i);
+               
+               texface[index].tpage = texpoly->tpage;
+               texface[index].flag = texpoly->flag;
+               texface[index].transp = texpoly->transp;
+               texface[index].mode = texpoly->mode;
+               texface[index].tile = texpoly->tile;
+               texface[index].unwrap = texpoly->unwrap;
+
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPUV, i);
+                       texface[index].uv[j][0] = mloopuv->uv[0];
+                       texface[index].uv[j][1] = mloopuv->uv[1];
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+
+       }
+       for(i=0; i < numCol; i++){
+               mcol = CustomData_get_layer_n(facedata,CD_MCOL, i);
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPCOL, i);
+                       mcol[(index*4) + j].r = mloopcol->r;
+                       mcol[(index*4) + j].g = mloopcol->g;
+                       mcol[(index*4) + j].b = mloopcol->b;
+                       mcol[(index*4) + j].a = mloopcol->a;
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+       }
+}
+
+
+static void BME_corners_to_loops(BME_Mesh *bm, CustomData *facedata, void *face_block, BME_Poly *f,int numCol, int numTex){
+       int i, j;
+       BME_Loop *l;
+       MTFace *texface;
+       MTexPoly *texpoly;
+       MCol *mcol;
+       MLoopCol *mloopcol;
+       MLoopUV *mloopuv;
+
+       for(i=0; i < numTex; i++){
+               texface = CustomData_em_get_n(facedata, face_block, CD_MTFACE, i);
+               texpoly = CustomData_bmesh_get_n(&bm->pdata, f->data, CD_MTEXPOLY, i);
+               
+               texpoly->tpage = texface->tpage;
+               texpoly->flag = texface->flag;
+               texpoly->transp = texface->transp;
+               texpoly->mode = texface->mode;
+               texpoly->tile = texface->tile;
+               texpoly->unwrap = texface->unwrap;
+
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPUV, i);
+                       mloopuv->uv[0] = texface->uv[j][0];
+                       mloopuv->uv[1] = texface->uv[j][1];
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+
+       }
+       for(i=0; i < numCol; i++){
+               mcol = CustomData_em_get_n(facedata, face_block, CD_MCOL, i);
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPCOL, i);
+                       mloopcol->r = mcol[j].r;
+                       mloopcol->g = mcol[j].g;
+                       mloopcol->b = mcol[j].b;
+                       mloopcol->a = mcol[j].a;
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+       }
+}
+
+static void BME_loops_to_corners(BME_Mesh *bm, CustomData *facedata, void *face_block, BME_Poly *f,int numCol, int numTex){
+       int i, j;
+       BME_Loop *l;
+       MTFace *texface;
+       MTexPoly *texpoly;
+       MCol *mcol;
+       MLoopCol *mloopcol;
+       MLoopUV *mloopuv;
+
+       for(i=0; i < numTex; i++){
+               texface = CustomData_em_get_n(facedata, face_block, CD_MTFACE, i);
+               texpoly = CustomData_bmesh_get_n(&bm->pdata, f->data, CD_MTEXPOLY, i);
+               
+               texface->tpage = texpoly->tpage;
+               texface->flag = texpoly->flag;
+               texface->transp = texpoly->transp;
+               texface->mode = texpoly->mode;
+               texface->tile = texpoly->tile;
+               texface->unwrap = texpoly->unwrap;
+
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPUV, i);
+                       texface->uv[j][0] = mloopuv->uv[0];
+                       texface->uv[j][1] = mloopuv->uv[1];
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+
+       }
+       for(i=0; i < numCol; i++){
+               mcol = CustomData_em_get_n(facedata, face_block, CD_MCOL, i);
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPCOL, i);
+                       mcol[j].r = mloopcol->r;
+                       mcol[j].g = mloopcol->g;
+                       mcol[j].b = mloopcol->b;
+                       mcol[j].a = mloopcol->a;
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+       }
+}
+/*move the EditMesh conversion functions to editmesh_tools.c*/
 BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) {
        BME_Mesh *bm;
-       int allocsize[4] = {512,512,2048,512};
-       BME_CustomDataInit *init = MEM_callocN(sizeof(BME_CustomDataInit) * 4, "Bmesh custom data init");
+       int allocsize[4] = {512,512,2048,512}, numTex, numCol;
        BME_Vert *v1, *v2;
        BME_Edge *e, *edar[4];
        BME_Poly *f;
@@ -68,9 +258,25 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) {
        EditFace *efa;
 
        int len;
-       bm = BME_make_mesh(allocsize,init);
+       bm = BME_make_mesh(allocsize);
+
+       /*copy custom data layout*/
+       CustomData_copy(&em->vdata, &bm->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&em->edata, &bm->edata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&em->fdata, &bm->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
+
+       /*copy face corner data*/
+       CustomData_to_bmeshpoly(&em->fdata, &bm->pdata, &bm->ldata);
+       /*initialize memory pools*/
+       CustomData_bmesh_init_pool(&bm->vdata, allocsize[0]);
+       CustomData_bmesh_init_pool(&bm->edata, allocsize[1]);
+       CustomData_bmesh_init_pool(&bm->ldata, allocsize[2]);
+       CustomData_bmesh_init_pool(&bm->pdata, allocsize[3]);
+       /*needed later*/
+       numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
+       numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL);
+
        BME_model_begin(bm);
-       
        /*add verts*/
        eve= em->verts.first;
        while(eve) {
@@ -79,9 +285,8 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) {
                v1->flag = eve->f;
                v1->h = eve->h;
                v1->bweight = eve->bweight;
-
-               /* link the verts for edge and face construction;
-                * kind of a dangerous thing - remember to cast back to BME_Vert before using! */
+               /*Copy Custom Data*/
+               CustomData_bmesh_copy_data(&em->vdata, &bm->vdata, eve->data, &v1->data);
                eve->tmp.v = (EditVert*)v1;
                eve = eve->next;
        }
@@ -99,13 +304,10 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) {
                if(eed->seam) e->flag |= ME_SEAM;
                if(eed->h & EM_FGON) e->flag |= ME_FGON;
                if(eed->h & 1) e->flag |= ME_HIDE;
-
-               /* link the edges for face construction;
-                * kind of a dangerous thing - remember to cast back to BME_Edge before using! */
                eed->tmp.e = (EditEdge*)e;
+               CustomData_bmesh_copy_data(&em->edata, &bm->edata, eed->data, &e->data);
                eed = eed->next;
        }
-
        /*add faces.*/
        efa= em->faces.first;
        while(efa) {
@@ -134,13 +336,13 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) {
                        if(efa->f & 1) f->flag |= ME_FACE_SEL;
                        else f->flag &= ~ME_FACE_SEL;
                }
+               CustomData_bmesh_copy_data(&em->fdata, &bm->pdata, efa->data, &f->data);
+               BME_corners_to_loops(bm, &em->fdata, efa->data, f,numCol,numTex);
                efa = efa->next;
        }
        BME_model_end(bm);
-       MEM_freeN(init);
        return bm;
 }
-
 /* adds the geometry in the bmesh to G.editMesh (does not free G.editMesh)
  * if td != NULL, the transdata will be mapped to the EditVert's co */
 EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
@@ -155,12 +357,21 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
        EditEdge *eed;
        EditFace *efa;
 
-       int totvert, len, i;
+       int totvert, len, i, numTex, numCol;
 
        em = G.editMesh;
 
        if (em == NULL) return NULL;
 
+
+       CustomData_copy(&bm->vdata, &em->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&bm->edata, &em->edata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&bm->pdata, &em->fdata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_from_bmeshpoly(&em->fdata, &bm->pdata, &bm->ldata,0);
+       numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
+       numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL);
+
+
        /* convert to EditMesh */
        /* make editverts */
        totvert = BLI_countlist(&(bm->verts));
@@ -176,6 +387,7 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
                eve1->f = (unsigned char)v1->flag;
                eve1->h = (unsigned char)v1->h;
                eve1->bweight = v1->bweight;
+               CustomData_em_copy_data(&bm->vdata, &em->vdata, v1->data, &eve1->data);
        }
        
        /* make edges */
@@ -191,6 +403,8 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
                        if(e->flag & ME_HIDE) eed->h |= 1;
                        if(G.scene->selectmode==SCE_SELECT_EDGE) 
                                EM_select_edge(eed, eed->f & SELECT);
+               
+                       CustomData_em_copy_data(&bm->edata, &em->edata, e->data, &eed->data);
                }
        }
 
@@ -217,6 +431,8 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
                        if(f->flag & ME_HIDE) efa->h= 1;
                        if((G.f & G_FACESELECT) && (efa->f & SELECT))
                                EM_select_face(efa, 1); /* flush down */
+                       CustomData_em_copy_data(&bm->pdata, &em->fdata, f->data, &efa->data);
+                       BME_loops_to_corners(bm, &em->fdata, efa->data, f,numCol,numTex);
                }
        }
 
@@ -234,18 +450,33 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm)
        
        BME_Mesh *bm;
        int allocsize[4] = {512,512,2048,512};
-       BME_CustomDataInit *init = MEM_callocN(sizeof(BME_CustomDataInit) * 4, "Bmesh custom data init");
        MVert *mvert, *mv;
        MEdge *medge, *me;
        MFace *mface, *mf;
-       int totface,totedge,totvert,i,len;
+       int totface,totedge,totvert,i,len, numTex, numCol;
        BME_Vert *v1=NULL,*v2=NULL, **vert_array;
        BME_Edge *e=NULL;
        BME_Poly *f=NULL;
        
        EdgeHash *edge_hash = BLI_edgehash_new();
 
-       bm = BME_make_mesh(allocsize,init);
+       bm = BME_make_mesh(allocsize);
+       /*copy custom data layout*/
+       CustomData_copy(&dm->vertData, &bm->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&dm->edgeData, &bm->edata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&dm->faceData, &bm->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
+
+       /*copy face corner data*/
+       CustomData_to_bmeshpoly(&dm->faceData, &bm->pdata, &bm->ldata);
+       /*initialize memory pools*/
+       CustomData_bmesh_init_pool(&bm->vdata, allocsize[0]);
+       CustomData_bmesh_init_pool(&bm->edata, allocsize[1]);
+       CustomData_bmesh_init_pool(&bm->ldata, allocsize[2]);
+       CustomData_bmesh_init_pool(&bm->pdata, allocsize[3]);
+       /*needed later*/
+       numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
+       numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL);
+
        totvert = dm->getNumVerts(dm);
        totedge = dm->getNumEdges(dm);
        totface = dm->getNumFaces(dm);
@@ -262,6 +493,7 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm)
                vert_array[i] = v1;
                v1->flag = mv->flag;
                v1->bweight = mv->bweight/255.0f;
+               CustomData_to_bmesh_block(&dm->vertData, &bm->vdata, i, &v1->data);
        }
        /*add edges*/
        for(i=0,me = medge; i < totedge;i++,me++){
@@ -272,6 +504,7 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm)
                e->bweight = me->bweight/255.0f;
                e->flag = (unsigned char)me->flag;
                BLI_edgehash_insert(edge_hash,me->v1,me->v2,e);
+               CustomData_to_bmesh_block(&dm->edgeData, &bm->edata, i, &e->data);
        }
        /*add faces.*/
        for(i=0,mf = mface; i < totface;i++,mf++){
@@ -295,12 +528,13 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm)
                f = BME_MF(bm,v1,v2,edar,len);
                f->mat_nr = mf->mat_nr;
                f->flag = mf->flag;
+               CustomData_to_bmesh_block(&dm->faceData,&bm->pdata,i,&f->data);
+               BME_DMcorners_to_loops(bm, &dm->faceData,i,f, numCol,numTex);
        }
        
        BME_model_end(bm);
        BLI_edgehash_free(edge_hash, NULL);
        MEM_freeN(vert_array);
-       MEM_freeN(init);
        return bm;
 }
 
@@ -309,7 +543,7 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
        MFace *mface, *mf;
        MEdge *medge, *me;
        MVert *mvert, *mv;
-       int totface,totedge,totvert,i,bmeshok,len;
+       int totface,totedge,totvert,i,bmeshok,len, numTex, numCol;
 
        BME_Vert *v1=NULL;
        BME_Edge *e=NULL, *oe=NULL;
@@ -345,12 +579,21 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
        
        /*convert back to mesh*/
        result = CDDM_from_template(dm,totvert,totedge,totface);
+       CustomData_merge(&bm->vdata, &result->vertData, CD_MASK_BMESH, CD_CALLOC, totvert);
+       CustomData_merge(&bm->edata, &result->edgeData, CD_MASK_BMESH, CD_CALLOC, totedge);
+       CustomData_merge(&bm->pdata, &result->faceData, CD_MASK_BMESH, CD_CALLOC, totface);
+       CustomData_from_bmeshpoly(&result->faceData, &bm->pdata, &bm->ldata,totface);
+       numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
+       numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL);
+
+
        /*Make Verts*/
        mvert = CDDM_get_verts(result);
        for(i=0,v1=bm->verts.first,mv=mvert;v1;v1=v1->next,i++,mv++){
                VECCOPY(mv->co,v1->co);
                mv->flag = (unsigned char)v1->flag;
                mv->bweight = (char)(255.0*v1->bweight);
+               CustomData_from_bmesh_block(&bm->vdata, &result->vertData, &v1->data, i);
        }
        medge = CDDM_get_edges(result);
        i=0;
@@ -368,6 +611,7 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
                        me->crease = (char)(255.0*e->crease);
                        me->bweight = (char)(255.0*e->bweight);
                        me->flag = e->flag;
+                       CustomData_from_bmesh_block(&bm->edata, &result->edgeData, &e->data, i);
                        me++;
                        i++;
                }
@@ -389,9 +633,11 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
                                if(mf->v3 == 0 || (len == 4 && mf->v4 == 0)){
                                        test_index_face(mf, NULL, i, len);
                                }
-                               i++;
                                mf->mat_nr = (unsigned char)f->mat_nr;
                                mf->flag = (unsigned char)f->flag;
+                               CustomData_from_bmesh_block(&bm->pdata, &result->faceData, &f->data, i);
+                               BME_DMloops_to_corners(bm, &result->faceData, i, f,numCol,numTex);
+                               i++;
                        }
                }
        }
index 3403f5829fe5f2ffd1326dcf1e9fef73fdaab6a7..801e0b8bdec9ff97cdf3115eb4228f890e9fdf05 100644 (file)
@@ -39,6 +39,7 @@
 #include "DNA_mesh_types.h"
 
 #include "BKE_utildefines.h"
+#include "BKE_customdata.h"
 #include "BKE_bmesh.h"
 
 #include "BLI_blenlib.h"
@@ -618,8 +619,8 @@ BME_Poly *BME_SFME(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Vert *v2, BME_Lo
        BME_disk_append_edge(e, v2);
        
        f2 = BME_addpolylist(bm,f);
-       f1loop = BME_create_loop(bm,v2,e,f,NULL);
-       f2loop = BME_create_loop(bm,v1,e,f2,NULL);
+       f1loop = BME_create_loop(bm,v2,e,f,v2loop);
+       f2loop = BME_create_loop(bm,v1,e,f2,v1loop);
        
        f1loop->prev = v2loop->prev;
        f2loop->prev = v1loop->prev;
@@ -663,16 +664,16 @@ BME_Poly *BME_SFME(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Vert *v2, BME_Lo
  *     Takes a an edge and pointer to one of its vertices and collapses
  *     the edge on that vertex.
  *     
- *     Before:             OE      KE
+ *     Before:    OE      KE
  *                      ------- -------
  *               |     ||      |
- *                             OV     KV      TV
+ *             OV     KV      TV
  *
  *
  *   After:             OE      
  *                      ---------------
  *               |             |
- *                             OV             TV
+ *             OV             TV
  *
  *
  *     Restrictions:
@@ -723,6 +724,8 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv)
                        /*remove ke from tv's disk cycle*/
                        BME_disk_remove_edge(ke, tv);
                
+                       
+
                        /*deal with radial cycle of ke*/
                        if(ke->loop){
                                /*first step, fix the neighboring loops of all loops in ke's radial cycle*/
@@ -763,6 +766,7 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv)
                                
                        }
                        
+
                        /*Validate disk cycles*/
                        diskbase = BME_disk_getpointer(ov->edge,ov);
                        edok = BME_cycle_validate(valance1, diskbase);
index 184ef2b8a0ea12e737c2a183d4d3979ac251fbab..ad46a7c1eb78b0ab4fd8fccc9fc3e1c82a4cfeaf 100644 (file)
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#include "MEM_guardedalloc.h"
 
+#include "MEM_guardedalloc.h"
 #include "DNA_listBase.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-
-
+#include "BLI_blenlib.h"
 #include "BKE_utildefines.h"
 #include "BKE_bmesh.h"
-#include "BKE_global.h"
-#include "BKE_depsgraph.h"
-#include "BLI_blenlib.h"
-#include "BLI_editVert.h"
-#include "BIF_editmesh.h"
-#include "BIF_space.h"
-#include "editmesh.h"
 #include "bmesh_private.h"
-#include "mydevice.h"
-
-#include "BSE_edit.h"
 
 
 /*     
  *     BME MAKE MESH
  *
  *  Allocates a new BME_Mesh structure.
- *     The arguments are two arrays, one of type int
- *  and another of type BME_CustomDataInit. The first array
- *  contains the allocation size for each element pool in 
- *  the mesh. For instance allocsize[0] contains the number
- *  of vertices to allocate at a time for the vertex pool.
- *
- *  The second array contains structures describing the layout
- *  of custom data for each element type in the mesh. So init[0]
- *  contains the custom data layout information for vertices, init[1]
- *  the layout information for edges and so on.
- *
  *  Returns -
  *  Pointer to a Bmesh
  *
 */
 
-BME_Mesh *BME_make_mesh(int allocsize[4], BME_CustomDataInit init[4])
+BME_Mesh *BME_make_mesh(int allocsize[4])
 {
        /*allocate the structure*/
        BME_Mesh *bm = MEM_callocN(sizeof(BME_Mesh),"BMesh");
        /*allocate the memory pools for the mesh elements*/
-       bm->vpool = BME_mempool_create(sizeof(BME_Vert), allocsize[0], allocsize[0]);
-       bm->epool = BME_mempool_create(sizeof(BME_Edge), allocsize[1], allocsize[1]);
-       bm->lpool = BME_mempool_create(sizeof(BME_Loop), allocsize[2], allocsize[2]);
-       bm->ppool = BME_mempool_create(sizeof(BME_Poly), allocsize[3], allocsize[3]);
-       /*Setup custom data layers*/
-       BME_CD_Create(&bm->vdata, &init[0], allocsize[0]);
-       BME_CD_Create(&bm->edata, &init[1], allocsize[1]);
-       BME_CD_Create(&bm->ldata, &init[2], allocsize[2]);
-       BME_CD_Create(&bm->pdata, &init[3], allocsize[3]);
+       bm->vpool = BLI_mempool_create(sizeof(BME_Vert), allocsize[0], allocsize[0]);
+       bm->epool = BLI_mempool_create(sizeof(BME_Edge), allocsize[1], allocsize[1]);
+       bm->lpool = BLI_mempool_create(sizeof(BME_Loop), allocsize[2], allocsize[2]);
+       bm->ppool = BLI_mempool_create(sizeof(BME_Poly), allocsize[3], allocsize[3]);
        return bm;
 }
 /*     
@@ -105,26 +74,35 @@ void BME_free_mesh(BME_Mesh *bm)
        BME_Loop *l;
        BME_Poly *f;
 
-       for(v=bm->verts.first; v; v=v->next) BME_CD_free_block(&bm->vdata, &v->data);
-       for(e=bm->edges.first; e; e=e->next) BME_CD_free_block(&bm->edata, &e->data);
+       for(v=bm->verts.first; v; v=v->next) CustomData_bmesh_free_block(&bm->vdata, &v->data);
+       for(e=bm->edges.first; e; e=e->next) CustomData_bmesh_free_block(&bm->edata, &e->data);
        for(f=bm->polys.first; f; f=f->next){
-               BME_CD_free_block(&bm->pdata, &f->data);
+               CustomData_bmesh_free_block(&bm->pdata, &f->data);
                l = f->loopbase;
                do{
-                       BME_CD_free_block(&bm->ldata, &l->data);
+                       CustomData_bmesh_free_block(&bm->ldata, &l->data);
                        l = l->next;
                }while(l!=f->loopbase);
        }
+
+       /*Free custom data pools, This should probably go in CustomData_free?*/
+       if(bm->vdata.totlayer) BLI_mempool_destroy(bm->vdata.pool);
+       if(bm->edata.totlayer) BLI_mempool_destroy(bm->edata.pool);
+       if(bm->ldata.totlayer) BLI_mempool_destroy(bm->ldata.pool);
+       if(bm->pdata.totlayer) BLI_mempool_destroy(bm->pdata.pool);
+
+       /*free custom data*/
+       CustomData_free(&bm->vdata,0);
+       CustomData_free(&bm->edata,0);
+       CustomData_free(&bm->ldata,0);
+       CustomData_free(&bm->pdata,0);
+
        /*destroy element pools*/
-       BME_mempool_destroy(bm->vpool);
-       BME_mempool_destroy(bm->epool);
-       BME_mempool_destroy(bm->ppool);
-       BME_mempool_destroy(bm->lpool);
-       /*free custom data pools*/
-       BME_CD_Free(&bm->vdata);
-       BME_CD_Free(&bm->edata);
-       BME_CD_Free(&bm->ldata);
-       BME_CD_Free(&bm->pdata);
+       BLI_mempool_destroy(bm->vpool);
+       BLI_mempool_destroy(bm->epool);
+       BLI_mempool_destroy(bm->ppool);
+       BLI_mempool_destroy(bm->lpool);
+       
        MEM_freeN(bm);  
 }
 
index cbf780c6467c76a106740b0c794e78fc47d90b74..ca27f5efd1058831cf2dd61b99346229f1f8db47 100644 (file)
 #include "BLI_blenlib.h"
 #include "BLI_linklist.h"
 #include "BLI_ghash.h"
-
-#include "BKE_customdata.h"
-
-/*
-       Simple, fast memory allocator for allocating many elements of the same size.
-*/
-typedef struct BME_mempool_chunk{
-       struct BME_mempool_chunk *next, *prev;
-       void *data;
-}BME_mempool_chunk;
-
-/*this is just to make things prettier*/
-typedef struct BME_freenode{
-       struct BME_freenode *next;
-}BME_freenode;
-
-BME_mempool *BME_mempool_create(int esize, int tote, int pchunk)
-{      BME_mempool  *pool = NULL;
-       BME_freenode *lasttail = NULL, *curnode = NULL;
-       int i,j, maxchunks;
-       char *addr;
-
-       /*allocate the pool structure*/
-       pool = MEM_mallocN(sizeof(BME_mempool),"memory pool");
-       pool->esize = esize;
-       pool->pchunk = pchunk;  
-       pool->csize = esize * pchunk;
-       pool->chunks.first = pool->chunks.last = NULL;
-       
-       maxchunks = tote / pchunk;
-       
-       /*allocate the actual chunks*/
-       for(i=0; i < maxchunks; i++){
-               BME_mempool_chunk *mpchunk = MEM_mallocN(sizeof(BME_mempool_chunk), "BME_Mempool Chunk");
-               mpchunk->next = mpchunk->prev = NULL;
-               mpchunk->data = MEM_mallocN(pool->csize, "BME Mempool Chunk Data");
-               BLI_addtail(&(pool->chunks), mpchunk);
-               
-               if(i==0) pool->free = mpchunk->data; /*start of the list*/
-               /*loop through the allocated data, building the pointer structures*/
-               for(addr = mpchunk->data, j=0; j < pool->pchunk; j++){
-                       curnode = ((BME_freenode*)addr);
-                       addr += pool->esize;
-                       curnode->next = (BME_freenode*)addr;
-               }
-               /*final pointer in the previously allocated chunk is wrong.*/
-               if(lasttail) lasttail->next = mpchunk->data;
-               /*set the end of this chunks memory to the new tail for next iteration*/
-               lasttail = curnode;
-       }
-       /*terminate the list*/
-       curnode->next = NULL;
-       return pool;
-}
-
-void *BME_mempool_alloc(BME_mempool *pool){
-       void *retval=NULL;
-       BME_freenode *curnode=NULL;
-       char *addr=NULL;
-       int j;
-
-       if(!(pool->free)){
-               /*need to allocate a new chunk*/
-               BME_mempool_chunk *mpchunk = MEM_mallocN(sizeof(BME_mempool_chunk), "BME_Mempool Chunk");
-               mpchunk->next = mpchunk->prev = NULL;
-               mpchunk->data = MEM_mallocN(pool->csize, "BME_Mempool Chunk Data");
-               BLI_addtail(&(pool->chunks), mpchunk);
-
-               pool->free = mpchunk->data; /*start of the list*/
-               for(addr = mpchunk->data, j=0; j < pool->pchunk; j++){
-                       curnode = ((BME_freenode*)addr);
-                       addr += pool->esize;
-                       curnode->next = (BME_freenode*)addr;
-               }
-               curnode->next = NULL; /*terminate the list*/
-       }
-
-       retval = pool->free;
-       pool->free = pool->free->next;
-       //memset(retval, 0, pool->esize);
-       return retval;
-}
-
-void BME_mempool_free(BME_mempool *pool, void *addr){ //doesnt protect against double frees, dont be stupid!
-       BME_freenode *newhead = addr;
-       newhead->next = pool->free;
-       pool->free = newhead;
-}
-void BME_mempool_destroy(BME_mempool *pool)
-{
-       BME_mempool_chunk *mpchunk=NULL;
-       for(mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) MEM_freeN(mpchunk->data);
-       BLI_freelistN(&(pool->chunks));
-       MEM_freeN(pool);
-}
 /**
  *     MISC utility functions.
  *
@@ -179,7 +84,7 @@ int BME_edge_swapverts(BME_Edge *e, BME_Vert *orig, BME_Vert *new){
 
 BME_Vert *BME_addvertlist(BME_Mesh *bm, BME_Vert *example){
        BME_Vert *v=NULL;
-       v = BME_mempool_alloc(bm->vpool);
+       v = BLI_mempool_alloc(bm->vpool);
        v->next = v->prev = NULL;
        v->EID = bm->nextv;
        v->co[0] = v->co[1] = v->co[2] = 0.0f;
@@ -195,16 +100,16 @@ BME_Vert *BME_addvertlist(BME_Mesh *bm, BME_Vert *example){
 
        if(example){
                VECCOPY(v->co,example->co);
-               BME_CD_copy_data(&bm->vdata, &bm->vdata, example->data, &v->data);
+               CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, example->data, &v->data);
        }
        else
-               BME_CD_set_default(&bm->vdata, &v->data);
+               CustomData_bmesh_set_default(&bm->vdata, &v->data);
 
        return v;
 }
 BME_Edge *BME_addedgelist(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Edge *example){
        BME_Edge *e=NULL;
-       e = BME_mempool_alloc(bm->epool);
+       e = BLI_mempool_alloc(bm->epool);
        e->next = e->prev = NULL;
        e->EID = bm->nexte;
        e->v1 = v1;
@@ -222,16 +127,16 @@ BME_Edge *BME_addedgelist(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Edge *ex
        BLI_addtail(&(bm->edges), e);
        
        if(example)
-               BME_CD_copy_data(&bm->edata, &bm->edata, example->data, &e->data);
+               CustomData_bmesh_copy_data(&bm->edata, &bm->edata, example->data, &e->data);
        else
-               BME_CD_set_default(&bm->edata, &e->data);
+               CustomData_bmesh_set_default(&bm->edata, &e->data);
 
 
        return e;
 }
 BME_Loop *BME_create_loop(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Poly *f, BME_Loop *example){
        BME_Loop *l=NULL;
-       l = BME_mempool_alloc(bm->lpool);
+       l = BLI_mempool_alloc(bm->lpool);
        l->next = l->prev = NULL;
        l->EID = bm->nextl;
        l->radial.next = l->radial.prev = NULL;
@@ -246,16 +151,16 @@ BME_Loop *BME_create_loop(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Poly *f, B
        bm->totloop++;
        
        if(example)
-               BME_CD_copy_data(&bm->ldata, &bm->ldata, example->data, &l->data);
+               CustomData_bmesh_copy_data(&bm->ldata, &bm->ldata, example->data, &l->data);
        else
-               BME_CD_set_default(&bm->ldata, &l->data);
+               CustomData_bmesh_set_default(&bm->ldata, &l->data);
 
        return l;
 }
 
 BME_Poly *BME_addpolylist(BME_Mesh *bm, BME_Poly *example){
        BME_Poly *f = NULL;
-       f = BME_mempool_alloc(bm->ppool);
+       f = BLI_mempool_alloc(bm->ppool);
        f->next = f->prev = NULL;
        f->EID = bm->nextp;
        f->loopbase = NULL;
@@ -268,9 +173,9 @@ BME_Poly *BME_addpolylist(BME_Mesh *bm, BME_Poly *example){
        bm->totpoly++;
 
        if(example)
-               BME_CD_copy_data(&bm->pdata, &bm->pdata, example->data, &f->data);
+               CustomData_bmesh_copy_data(&bm->pdata, &bm->pdata, example->data, &f->data);
        else
-               BME_CD_set_default(&bm->pdata, &f->data);
+               CustomData_bmesh_set_default(&bm->pdata, &f->data);
 
 
        return f;
@@ -281,23 +186,23 @@ BME_Poly *BME_addpolylist(BME_Mesh *bm, BME_Poly *example){
 */
 void BME_free_vert(BME_Mesh *bm, BME_Vert *v){
        bm->totvert--;
-       BME_CD_free_block(&bm->vdata, &v->data);
-       BME_mempool_free(bm->vpool, v);
+       CustomData_bmesh_free_block(&bm->vdata, &v->data);
+       BLI_mempool_free(bm->vpool, v);
 }
 void BME_free_edge(BME_Mesh *bm, BME_Edge *e){
        bm->totedge--;
-       BME_CD_free_block(&bm->edata, &e->data);
-       BME_mempool_free(bm->epool, e);
+       CustomData_bmesh_free_block(&bm->edata, &e->data);
+       BLI_mempool_free(bm->epool, e);
 }
 void BME_free_poly(BME_Mesh *bm, BME_Poly *f){
        bm->totpoly--;
-       BME_CD_free_block(&bm->pdata, &f->data);
-       BME_mempool_free(bm->ppool, f);
+       CustomData_bmesh_free_block(&bm->pdata, &f->data);
+       BLI_mempool_free(bm->ppool, f);
 }
 void BME_free_loop(BME_Mesh *bm, BME_Loop *l){
        bm->totloop--;
-       BME_CD_free_block(&bm->ldata, &l->data);
-       BME_mempool_free(bm->lpool, l);
+       CustomData_bmesh_free_block(&bm->ldata, &l->data);
+       BLI_mempool_free(bm->lpool, l);
 }
 /**
  *     BMESH CYCLES
index 7ce967d1d22662735b2bf73e30bfc3d6eae3094f..90259031e5caa3e42e22ba9ef9ed75a64e5d336e 100644 (file)
@@ -205,7 +205,53 @@ static BME_Poly *BME_split_face(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Ver
        return nf;
 }
 
-/* a wrapper for BME_SEMV that transfers element flags */
+
+static void BME_data_interp_from_verts(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Vert *v, float fac)
+{
+       void *src[2];
+       float w[2];
+       if (v1->data && v2->data) {
+               src[0]= v1->data;
+               src[1]= v2->data;
+               w[0] = 1.0f-fac;
+               w[1] = fac;
+               CustomData_bmesh_interp(&bm->vdata, src, w, NULL, 2, v->data);
+       }
+}
+
+
+static void BME_data_facevert_edgesplit(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Vert *v, BME_Edge *e1, float fac){
+       void *src[2];
+       float w[2];
+       BME_Loop *l=NULL, *v1loop = NULL, *vloop = NULL, *v2loop = NULL;
+       
+       w[0] = 1.0f - fac;
+       w[1] = fac;
+
+       if(!e1->loop) return;
+       l = e1->loop;
+       do{
+               if(l->v == v1){ 
+                       v1loop = l;
+                       vloop = v1loop->next;
+                       v2loop = vloop->next;
+               }else if(l->v == v){
+                       v1loop = l->next;
+                       vloop = l;
+                       v2loop = l->prev;
+                       
+               }
+
+               src[0] = v1loop->data;
+               src[1] = v2loop->data;                                  
+
+               CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, vloop->data);                               
+               l = l->radial.next->data;
+       }while(l!=e1->loop);
+}
+
+
+/* a wrapper for BME_SEMV that transfers element flags */ /*add custom data interpolation in here!*/
 static BME_Vert *BME_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Edge **ne, float percent) {
        BME_Vert *nv, *v2;
        float len;
@@ -224,10 +270,39 @@ static BME_Vert *BME_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Edge
                (*ne)->crease = e->crease;
                (*ne)->bweight = e->bweight;
        }
-
+       /*v->nv->v2*/
+       BME_data_facevert_edgesplit(bm,v2, v, nv, e, 0.75);     
        return nv;
 }
 
+static void BME_collapse_vert(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv, float fac){
+       void *src[2];
+       float w[2];
+       BME_Loop *l=NULL, *kvloop=NULL, *tvloop=NULL;
+       BME_Vert *tv = BME_edge_getothervert(ke,kv);
+
+       w[0] = 1.0f - fac;
+       w[1] = fac;
+
+       if(ke->loop){
+               l = ke->loop;
+               do{
+                       if(l->v == tv && l->next->v == kv){
+                               tvloop = l;
+                               kvloop = l->next;
+
+                               src[0] = kvloop->data;
+                               src[1] = tvloop->data;
+                               CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, kvloop->data);                                                              
+                       }
+                       l=l->radial.next->data;
+               }while(l!=ke->loop);
+       }
+       BME_JEKV(bm,ke,kv);
+}
+
+
+
 static int BME_bevel_is_split_vert(BME_Loop *l) {
        /* look for verts that have already been added to the edge when
         * beveling other polys; this can be determined by testing the
@@ -315,7 +390,7 @@ static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int
  * Finally, return the split vert. */
 static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, BME_Loop *l, float *up_vec, float value, BME_TransData_Head *td) {
        BME_TransData *vtd, *vtd1, *vtd2;
-       BME_Vert *sv, *v2, *v3;
+       BME_Vert *sv, *v2, *v3, *ov;
        BME_Loop *lv1, *lv2;
        BME_Edge *ne, *e1, *e2;
        float maxfactor, scale, len, dis, vec1[3], vec2[3], t_up_vec[3];
@@ -349,7 +424,11 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
                else {
                        e1 = e2;
                }
+               ov = BME_edge_getothervert(e1,v);
                sv = BME_split_edge(bm,v,e1,&ne,0);
+               //BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /*this is technically wrong...*/
+               //BME_data_interp_from_faceverts(bm, v, ov, sv, 0.25);
+               //BME_data_interp_from_faceverts(bm, ov, v, sv, 0.25);
                BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1, NULL); /* quick default */
                sv->tflag1 |= BME_BEVEL_BEVEL;
                ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
@@ -388,7 +467,11 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
                }
                else {
                        is_split_vert = 0;
+                       ov = BME_edge_getothervert(l->e,v);
                        sv = BME_split_edge(bm,v,l->e,&ne,0);
+                       //BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /*this is technically wrong...*/
+                       //BME_data_interp_from_faceverts(bm, v, ov, sv, 0.25);
+                       //BME_data_interp_from_faceverts(bm, ov, v, sv, 0.25);
                        BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1, NULL); /* quick default */
                        sv->tflag1 |= BME_BEVEL_BEVEL;
                        ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
@@ -567,12 +650,15 @@ static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int opti
                if (kl->v == kv) {
                        BME_split_face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e);
                        BME_JFKE(bm,((BME_Loop*)kl->prev->radial.next->data)->f,kl->f,kl->prev->e);
-                       BME_JEKV(bm,kl->e,kv);
+                       BME_collapse_vert(bm, kl->e, kv, 1.0);
+                       //BME_JEKV(bm,kl->e,kv);
+                       
                }
                else {
                        BME_split_face(bm,kl->f,kl->next->next->v,kl->v,&nl,kl->next->e);
                        BME_JFKE(bm,((BME_Loop*)kl->next->radial.next->data)->f,kl->f,kl->next->e);
-                       BME_JEKV(bm,kl->e,kv);
+                       BME_collapse_vert(bm, kl->e, kv, 1.0);
+                       //BME_JEKV(bm,kl->e,kv);
                }
                l = l->prev;
        }
@@ -601,12 +687,14 @@ static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int opti
                if (kl->v == kv) {
                        BME_split_face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e);
                        BME_JFKE(bm,((BME_Loop*)kl->prev->radial.next->data)->f,kl->f,kl->prev->e);
-                       BME_JEKV(bm,kl->e,kv);
+                       BME_collapse_vert(bm, kl->e, kv, 1.0);
+                       //BME_JEKV(bm,kl->e,kv);
                }
                else {
                        BME_split_face(bm,kl->f,kl->next->next->v,kl->v,&nl,kl->next->e);
                        BME_JFKE(bm,((BME_Loop*)kl->next->radial.next->data)->f,kl->f,kl->next->e);
-                       BME_JEKV(bm,kl->e,kv);
+                       BME_collapse_vert(bm, kl->e, kv, 1.0);
+                       //BME_JEKV(bm,kl->e,kv);
                }
        }
 
@@ -1073,7 +1161,8 @@ static void bmesh_dissolve_disk(BME_Mesh *bm, BME_Vert *v){
                                e = BME_disk_nextedge(e,v);
                        }while(e != v->edge);
                }
-               BME_JEKV(bm,v->edge,v);
+               BME_collapse_vert(bm, v->edge, v, 1.0);
+               //BME_JEKV(bm,v->edge,v);
        }
 }
 static BME_Mesh *BME_bevel_mesh(BME_Mesh *bm, float value, int res, int options, int defgrp_index, BME_TransData_Head *td) {
index 3040566065818b7c1d6d68f04e8012048986f126..4d3f9143b851699cb13e45f61795e768542895d7 100644 (file)
@@ -1052,7 +1052,7 @@ void emDM_copyEdgeArray(DerivedMesh *dm, MEdge *edge_r)
 
        /* store vertex indices in tmp union */
        for(ev = em->verts.first, i = 0; ev; ev = ev->next, ++i)
-               ev->tmp.l = (long) i++;
+               ev->tmp.l = (long) i;
 
        for( ; ee; ee = ee->next, ++edge_r) {
                edge_r->crease = (unsigned char) (ee->crease*255.0f);
index 05f2e69fce1bb34f2cc66a66e74e1f2900bb8a12..5b96bf110566cecceb0fb21dba124d84ec07a60e 100644 (file)
@@ -350,7 +350,7 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan
        pchan->flag= chan->flag;
        
        con= chan->constraints.first;
-       for(pcon= pchan->constraints.first; pcon; pcon= pcon->next) {
+       for(pcon= pchan->constraints.first; pcon; pcon= pcon->next, con= con->next) {
                pcon->enforce= con->enforce;
                pcon->headtail= con->headtail;
        }
index 4aa2a85b8b1e4dc477bab4258d8bf810b97db9d5..f34ef0090f39d1126583c95b038efe6238b372b3 100644 (file)
 
 #include "BKE_bmesh.h"
 
-struct BME_mempool *BME_mempool_create(int esize, int tote, int pchunk);
-void BME_mempool_destroy(struct BME_mempool *pool);
-void *BME_mempool_alloc(struct BME_mempool *pool);
-void BME_mempool_free(struct BME_mempool *pool, void *address);
-
 /*ALLOCATION/DEALLOCATION*/
 struct BME_Vert *BME_addvertlist(struct BME_Mesh *bm, struct BME_Vert *example);
 struct BME_Edge *BME_addedgelist(struct BME_Mesh *bm, struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Edge *example);
@@ -54,7 +49,6 @@ void BME_free_vert(struct BME_Mesh *bm, struct BME_Vert *v);
 void BME_free_edge(struct BME_Mesh *bm, struct BME_Edge *e);
 void BME_free_poly(struct BME_Mesh *bm, struct BME_Poly *f);
 void BME_free_loop(struct BME_Mesh *bm, struct BME_Loop *l);
-//void BME_delete_loop(struct BME_Mesh *bm, struct BME_Loop *l);
 
 /*DOUBLE CIRCULAR LINKED LIST FUNCTIONS*/
 void BME_cycle_append(void *h, void *nt);
index 6034b85e20f998342f13b15f4b1ee8918e460a47..c7817b017ef454bfe4dd5dbb5b5193a9ad3a5d18 100644 (file)
@@ -132,7 +132,7 @@ void cloth_init ( ClothModifierData *clmd )
        
        clmd->coll_parms->self_friction = 5.0;
        clmd->coll_parms->friction = 5.0;
-       clmd->coll_parms->loop_count = 3;
+       clmd->coll_parms->loop_count = 2;
        clmd->coll_parms->epsilon = 0.015f;
        clmd->coll_parms->flags = CLOTH_COLLSETTINGS_FLAG_ENABLED;
        clmd->coll_parms->collision_list = NULL;
@@ -471,7 +471,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
 
        tend();
 
-       /* printf ( "Cloth simulation time: %f\n", ( float ) tval() ); */
+       // printf ( "%f\n", ( float ) tval() );
        
        return ret;
 }
index 7f41ca033d330183c749c42f6a2fa83de57fcda1..26c5d186d8703b995d22aca66ccd1ede9d293ece 100644 (file)
@@ -541,7 +541,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier
                        {
                                Normalize ( vrel_t_pre );
 
-                               impulse = 2.0 * magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3 );
+                               impulse = magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); // 2.0 * 
                                VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse );
                                VECADDMUL ( cloth1->verts[collpair->ap2].impulse, vrel_t_pre, w2 * impulse );
                                VECADDMUL ( cloth1->verts[collpair->ap3].impulse, vrel_t_pre, w3 * impulse );
@@ -1291,52 +1291,223 @@ int cloth_collision_moving ( ClothModifierData *clmd, CollisionModifierData *col
        return 1;
 }
 
-int cloth_bvh_objcollisions_do ( ClothModifierData * clmd, CollisionModifierData *collmd, float step, float dt )
-{
+int cloth_do_selfcollisions(ClothModifierData * clmd)
+{      
+       int ret2 = 0, l;
        Cloth *cloth = clmd->clothObject;
-       BVHTree *cloth_bvh= ( BVHTree * ) cloth->bvhtree;
-       long i=0, j = 0, numfaces = 0, numverts = 0;
-       ClothVertex *verts = NULL;
-       CollPair *collisions = NULL, *collisions_index = NULL;
-       int ret = 0;
-       int result = 0;
-       float tnull[3] = {0,0,0};
-       BVHTreeOverlap *overlap = NULL;
-
-
-       numfaces = clmd->clothObject->numfaces;
-       numverts = clmd->clothObject->numverts;
-
-       verts = cloth->verts;
+       
+       if ( clmd->clothObject->bvhselftree )
+       {
+               for(l = 0; l < clmd->coll_parms->self_loop_count; l++)
+               {
+                       BVHTreeOverlap *overlap = NULL;
+                       ClothVertex *verts = clmd->clothObject->verts; // needed for openMP
+                       int k;
+                       int ret = 0, result = 0;
+                       
+                       // search for overlapping collision pairs 
+                       overlap = BLI_bvhtree_overlap ( cloth->bvhselftree, cloth->bvhselftree, &result );
+       
+// #pragma omp parallel for private(k, i, j) schedule(static)
+                       for ( k = 0; k < result; k++ )
+                       {
+                               float temp[3];
+                               float length = 0;
+                               float mindistance;
+                               int i, j;
+       
+                               i = overlap[k].indexA;
+                               j = overlap[k].indexB;
+       
+                               mindistance = clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len + cloth->verts[j].avg_spring_len );
+       
+                               if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
+                               {
+                                       if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED )
+                                       && ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) )
+                                       {
+                                               continue;
+                                       }
+                               }
+       
+                               VECSUB ( temp, verts[i].tx, verts[j].tx );
+       
+                               if ( ( ABS ( temp[0] ) > mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) continue;
+       
+                               // check for adjacent points (i must be smaller j)
+                               if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) )
+                               {
+                                       continue;
+                               }
+       
+                               length = Normalize ( temp );
+       
+                               if ( length < mindistance )
+                               {
+                                       float correction = mindistance - length;
+       
+                                       if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED )
+                                       {
+                                               VecMulf ( temp, -correction );
+                                               VECADD ( verts[j].tx, verts[j].tx, temp );
+                                       }
+                                       else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED )
+                                       {
+                                               VecMulf ( temp, correction );
+                                               VECADD ( verts[i].tx, verts[i].tx, temp );
+                                       }
+                                       else
+                                       {
+                                               VecMulf ( temp, -correction*0.5 );
+                                               VECADD ( verts[j].tx, verts[j].tx, temp );
+       
+                                               VECSUB ( verts[i].tx, verts[i].tx, temp );
+                                       }
+                                       ret = 1;
+                                       ret2 += ret;
+                               }
+                               else
+                               {
+                                       // check for approximated time collisions
+                               }
+                       }
+       
+                       if ( overlap )
+                               MEM_freeN ( overlap );
+               
+                       if(!ret)
+                               break;
+                       
+               }
+               ////////////////////////////////////////////////////////////
+       
+               ////////////////////////////////////////////////////////////
+               // SELFCOLLISIONS: update velocities
+               ////////////////////////////////////////////////////////////
+               if ( ret2 )
+               {
+                       int i; 
+                       ClothVertex *verts = clmd->clothObject->verts; // needed for openMP
+                       
+                       for ( i = 0; i < cloth->numverts; i++ )
+                       {
+                               if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) )
+                               {
+                                       VECSUB ( verts[i].tv, verts[i].tx, verts[i].txold );
+                               }
+                       }
+               }
+               ////////////////////////////////////////////////////////////
+       }
+       return ret2;
+}
 
-       if ( collmd->bvhtree )
+// return all collision objects in scene
+// collision object will exclude self 
+CollisionModifierData **get_collisionobjects(Object *self, int *numcollobj)
+{
+       Base *base=NULL;
+       CollisionModifierData **objs = NULL;
+       Object *coll_ob = NULL;
+       CollisionModifierData *collmd = NULL;
+       int numobj = 0, maxobj = 100;
+       
+       objs = MEM_callocN(sizeof(CollisionModifierData *)*maxobj, "CollisionObjectsArray");
+       // check all collision objects
+       for ( base = G.scene->base.first; base; base = base->next )
        {
-               /* get pointer to bounding volume hierarchy */
-               BVHTree *coll_bvh = collmd->bvhtree;
+               coll_ob = base->object;
+               collmd = ( CollisionModifierData * ) modifiers_findByType ( coll_ob, eModifierType_Collision );
+       
+               if ( !collmd )
+               {
+                       if ( coll_ob->dup_group )
+                       {
+                               GroupObject *go;
+                               Group *group = coll_ob->dup_group;
 
-               /* move object to position (step) in time */
-               collision_move_object ( collmd, step + dt, step );
+                               for ( go= group->gobject.first; go; go= go->next )
+                               {
+                                       coll_ob = go->ob;
 
-               /* search for overlapping collision pairs */
-               overlap = BLI_bvhtree_overlap ( cloth_bvh, coll_bvh, &result );
+                                       collmd = ( CollisionModifierData * ) modifiers_findByType ( coll_ob, eModifierType_Collision );
 
-               collisions = ( CollPair* ) MEM_mallocN ( sizeof ( CollPair ) * result*4, "collision array" ); //*4 since cloth_collision_static can return more than 1 collision
-               collisions_index = collisions;
+                                       if ( !collmd )
+                                               continue;
 
-               for ( i = 0; i < result; i++ )
-               {
-                       collisions_index = cloth_collision ( ( ModifierData * ) clmd, ( ModifierData * ) collmd, overlap+i, collisions_index );
-               }
+                                       if(coll_ob == self)
+                                               continue;
 
-               if ( overlap )
-                       MEM_freeN ( overlap );
+                                       if(numobj >= maxobj)
+                                       {
+                                               // realloc
+                                               int oldmax = maxobj;
+                                               CollisionModifierData **tmp;
+                                               maxobj *= 2;
+                                               tmp = MEM_callocN(sizeof(CollisionModifierData *)*maxobj, "CollisionObjectsArray");
+                                               memcpy(tmp, objs, sizeof(CollisionModifierData *)*oldmax);
+                                               MEM_freeN(objs);
+                                               objs = tmp;
+                                       }
+                                       
+                                       objs[numobj] = collmd;
+                                       numobj++;
+                               }
+                       }
+               }
+               else
+               {
+                       if(coll_ob == self)
+                               continue;
+                       
+                       if(numobj >= maxobj)
+                       {
+                               // realloc
+                               int oldmax = maxobj;
+                               CollisionModifierData **tmp;
+                               maxobj *= 2;
+                               tmp = MEM_callocN(sizeof(CollisionModifierData *)*maxobj, "CollisionObjectsArray");
+                               memcpy(tmp, objs, sizeof(CollisionModifierData *)*oldmax);
+                               MEM_freeN(objs);
+                               objs = tmp;
+                               
+                       }
+                       
+                       objs[numobj] = collmd;
+                       numobj++;
+               }       
        }
-       else
+       *numcollobj = numobj;
+       return objs;
+}
+
+void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, CollisionModifierData *collmd, CollPair **collisions, CollPair **collisions_index, int numresult, BVHTreeOverlap *overlap)
+{
+       int i;
+       
+       *collisions = ( CollPair* ) MEM_mallocN ( sizeof ( CollPair ) * numresult * 4, "collision array" ); //*4 since cloth_collision_static can return more than 1 collision
+       *collisions_index = *collisions;
+
+       for ( i = 0; i < numresult; i++ )
        {
-               if ( G.rt > 0 )
-                       printf ( "cloth_bvh_objcollision: found a collision object with clothObject or collData NULL.\n" );
+               *collisions_index = cloth_collision ( ( ModifierData * ) clmd, ( ModifierData * ) collmd, overlap+i, *collisions_index );
        }
+}
 
+int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, CollisionModifierData *collmd, CollPair *collisions, CollPair *collisions_index)
+{
+       Cloth *cloth = clmd->clothObject;
+       int i=0, j = 0, numfaces = 0, numverts = 0;
+       ClothVertex *verts = NULL;
+       int ret = 0;
+       int result = 0;
+       float tnull[3] = {0,0,0};
+       
+       numfaces = clmd->clothObject->numfaces;
+       numverts = clmd->clothObject->numverts;
+       verts = cloth->verts;
+       
        // process all collisions (calculate impulses, TODO: also repulses if distance too short)
        result = 1;
        for ( j = 0; j < 5; j++ ) // 5 is just a value that ensures convergence
@@ -1363,48 +1534,22 @@ int cloth_bvh_objcollisions_do ( ClothModifierData * clmd, CollisionModifierData
                                        }
                                }
                        }
-/*
-                       result += cloth_collision_moving ( clmd, collmd, collisions, collisions_index );
-
-                       // apply impulses in parallel
-                       if ( result )
-                       {
-                               for ( i = 0; i < numverts; i++ )
-                               {
-                                       // calculate "velocities" (just xnew = xold + v; no dt in v)
-                                       if ( verts[i].impulse_count )
-                                       {
-                                               VECADDMUL ( verts[i].tv, verts[i].impulse, 1.0f / verts[i].impulse_count );
-                                               VECCOPY ( verts[i].impulse, tnull );
-                                               verts[i].impulse_count = 0;
-
-                                               ret++;
-                                       }
-                               }
-                       }
-*/
                }
        }
-
-       if ( collisions ) MEM_freeN ( collisions );
-
        return ret;
 }
 
 // cloth - object collisions
-int cloth_bvh_objcollision ( ClothModifierData * clmd, float step, float dt )
+int cloth_bvh_objcollision ( Object *ob, ClothModifierData * clmd, float step, float dt )
 {
-       Base *base=NULL;
-       CollisionModifierData *collmd=NULL;
        Cloth *cloth=NULL;
-       Object *coll_ob=NULL;
        BVHTree *cloth_bvh=NULL;
-       long i=0, j = 0, k = 0, l = 0, numfaces = 0, numverts = 0;
-       int result = 0, rounds = 0; // result counts applied collisions; ic is for debug output;
+       long i=0, numfaces = 0, numverts = 0;
+       int rounds = 0; // result counts applied collisions; ic is for debug output;
        ClothVertex *verts = NULL;
        int ret = 0, ret2 = 0;
-       ClothModifierData *tclmd;
-       int collisions = 0;
+       CollisionModifierData **collobjs = NULL;
+       int numcollobj = 0;
 
        if ( ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ ) || ! ( ( ( Cloth * ) clmd->clothObject )->bvhtree ) )
        {
@@ -1424,54 +1569,61 @@ int cloth_bvh_objcollision ( ClothModifierData * clmd, float step, float dt )
        // update cloth bvh
        bvhtree_update_from_cloth ( clmd, 1 ); // 0 means STATIC, 1 means MOVING (see later in this function)
        bvhselftree_update_from_cloth ( clmd, 0 ); // 0 means STATIC, 1 means MOVING (see later in this function)
+       
+       collobjs = get_collisionobjects(ob, &numcollobj);
+       
+       if(!collobjs)
+               return 0;
 
        do
        {
-               result = 0;
+               CollPair **collisions, **collisions_index;
+               
                ret2 = 0;
 
+               collisions = MEM_callocN(sizeof(CollPair *) *numcollobj , "CollPair");
+               collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj , "CollPair");
+               
                // check all collision objects
-               for ( base = G.scene->base.first; base; base = base->next )
+               for(i = 0; i < numcollobj; i++)
                {
-                       coll_ob = base->object;
-                       collmd = ( CollisionModifierData * ) modifiers_findByType ( coll_ob, eModifierType_Collision );
-
-                       if ( !collmd )
-                       {
-                               if ( coll_ob->dup_group )
-                               {
-                                       GroupObject *go;
-                                       Group *group = coll_ob->dup_group;
-
-                                       for ( go= group->gobject.first; go; go= go->next )
-                                       {
-                                               coll_ob = go->ob;
-
-                                               collmd = ( CollisionModifierData * ) modifiers_findByType ( coll_ob, eModifierType_Collision );
-
-                                               if ( !collmd )
-                                                       continue;
-
-                                               tclmd = ( ClothModifierData * ) modifiers_findByType ( coll_ob, eModifierType_Cloth );
-                                               if ( tclmd == clmd )
-                                                       continue;
-
-                                               ret += cloth_bvh_objcollisions_do ( clmd, collmd, step, dt );
-                                               ret2 += ret;
-                                       }
-                               }
-                       }
-                       else
+                       CollisionModifierData *collmd = collobjs[i];
+                       BVHTreeOverlap *overlap = NULL;
+                       int result = 0;
+                       
+                       /* move object to position (step) in time */
+                       collision_move_object ( collmd, step + dt, step );
+                       
+                       /* search for overlapping collision pairs */
+                       overlap = BLI_bvhtree_overlap ( cloth_bvh, collmd->bvhtree, &result );
+                               
+                       // go to next object if no overlap is there
+                       if(!result || !overlap)
                        {
-                               tclmd = ( ClothModifierData * ) modifiers_findByType ( coll_ob, eModifierType_Cloth );
-                               if ( tclmd == clmd )
-                                       continue;
-
-                               ret += cloth_bvh_objcollisions_do ( clmd, collmd, step, dt );
-                               ret2 += ret;
+                               if ( overlap )
+                                       MEM_freeN ( overlap );
+                               continue;
                        }
+                       
+                       /* check if collisions really happen (costly near check) */
+                       cloth_bvh_objcollisions_nearcheck ( clmd, collmd, &collisions[i], &collisions_index[i], result, overlap);
+                       
+                       // resolve nearby collisions
+                       ret += cloth_bvh_objcollisions_resolve ( clmd, collmd, collisions[i],  collisions_index[i]);
+                       ret2 += ret;
+                       
+                       if ( overlap )
+                               MEM_freeN ( overlap );
                }
                rounds++;
+               
+               for(i = 0; i < numcollobj; i++)
+               {
+                       if ( collisions[i] ) MEM_freeN ( collisions[i] );
+               }
+                       
+               MEM_freeN(collisions);
+               MEM_freeN(collisions_index);
 
                ////////////////////////////////////////////////////////////
                // update positions
@@ -1493,117 +1645,20 @@ int cloth_bvh_objcollision ( ClothModifierData * clmd, float step, float dt )
                }
                ////////////////////////////////////////////////////////////
 
-
+               
                ////////////////////////////////////////////////////////////
                // Test on *simple* selfcollisions
                ////////////////////////////////////////////////////////////
                if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF )
                {
-                       for(l = 0; l < clmd->coll_parms->self_loop_count; l++)
-                       {
-                               // TODO: add coll quality rounds again
-                               BVHTreeOverlap *overlap = NULL;
-       
-                               collisions = 1;
-                               verts = cloth->verts; // needed for openMP
-       
-                               numfaces = clmd->clothObject->numfaces;
-                               numverts = clmd->clothObject->numverts;
-       
-                               verts = cloth->verts;
-       
-                               if ( cloth->bvhselftree )
-                               {
-                                       // search for overlapping collision pairs 
-                                       overlap = BLI_bvhtree_overlap ( cloth->bvhselftree, cloth->bvhselftree, &result );
-       
-       // #pragma omp parallel for private(k, i, j) schedule(static)
-                                       for ( k = 0; k < result; k++ )
-                                       {
-                                               float temp[3];
-                                               float length = 0;
-                                               float mindistance;
-       
-                                               i = overlap[k].indexA;
-                                               j = overlap[k].indexB;
-       
-                                               mindistance = clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len + cloth->verts[j].avg_spring_len );
-       
-                                               if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
-                                               {
-                                                       if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED )
-                                                               && ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) )
-                                                       {
-                                                               continue;
-                                                       }
-                                               }
-       
-                                               VECSUB ( temp, verts[i].tx, verts[j].tx );
-       
-                                               if ( ( ABS ( temp[0] ) > mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) continue;
-       
-                                               // check for adjacent points (i must be smaller j)
-                                               if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) )
-                                               {
-                                                       continue;
-                                               }
-       
-                                               length = Normalize ( temp );
-       
-                                               if ( length < mindistance )
-                                               {
-                                                       float correction = mindistance - length;
-       
-                                                       if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED )
-                                                       {
-                                                               VecMulf ( temp, -correction );
-                                                               VECADD ( verts[j].tx, verts[j].tx, temp );
-                                                       }
-                                                       else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED )
-                                                       {
-                                                               VecMulf ( temp, correction );
-                                                               VECADD ( verts[i].tx, verts[i].tx, temp );
-                                                       }
-                                                       else
-                                                       {
-                                                               VecMulf ( temp, -correction*0.5 );
-                                                               VECADD ( verts[j].tx, verts[j].tx, temp );
-       
-                                                               VECSUB ( verts[i].tx, verts[i].tx, temp );
-                                                       }
-                                                       ret = 1;
-                                                       ret2 += ret;
-                                               }
-                                               else
-                                               {
-                                                       // check for approximated time collisions
-                                               }
-                                       }
-       
-                                       if ( overlap )
-                                               MEM_freeN ( overlap );
-       
-                               }
-                       }
-                       ////////////////////////////////////////////////////////////
-
-                       ////////////////////////////////////////////////////////////
-                       // SELFCOLLISIONS: update velocities
-                       ////////////////////////////////////////////////////////////
-                       if ( ret2 )
-                       {
-                               for ( i = 0; i < cloth->numverts; i++ )
-                               {
-                                       if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) )
-                                       {
-                                               VECSUB ( verts[i].tv, verts[i].tx, verts[i].txold );
-                                       }
-                               }
-                       }
-                       ////////////////////////////////////////////////////////////
+                       ret2 += cloth_do_selfcollisions(clmd);
                }
+               ////////////////////////////////////////////////////////////
        }
        while ( ret2 && ( clmd->coll_parms->loop_count>rounds ) );
+       
+       if(collobjs)
+               +               MEM_freeN(collobjs);
 
        return MIN2 ( ret, 1 );
 }
index 77068d8ed6647fa729b96966c8edf51ce6ed05e1..501293ecd814970d8ddc9a4e2a64cd4edc08a439 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_linklist.h"
+#include "BLI_mempool.h"
 
 #include "DNA_customdata_types.h"
 #include "DNA_listBase.h"
@@ -359,8 +360,80 @@ static void layerDefault_origspace_face(void *data, int count)
 }
 /* --------- */
 
+static void layerDefault_mloopcol(void *data, int count)
+{
+       static MLoopCol default_mloopcol = {255,255,255,255};
+       MLoopCol *mlcol = (MLoopCol*)data;
+       int i;
+       for(i = 0; i < count; i++)
+               mlcol[i] = default_mloopcol;
+
+}
+
+static void layerInterp_mloopcol(void **sources, float *weights,
+                               float *sub_weights, int count, void *dest)
+{
+       MLoopCol *mc = dest;
+       int i;
+       float *sub_weight;
+       struct {
+               float a;
+               float r;
+               float g;
+               float b;
+       } col;
+       col.a = col.r = col.g = col.b = 0;
 
+       sub_weight = sub_weights;
+       for(i = 0; i < count; ++i){
+               float weight = weights ? weights[i] : 1;
+               MLoopCol *src = sources[i];
+               if(sub_weights){
+                       col.a += src->a * (*sub_weight) * weight;
+                       col.r += src->r * (*sub_weight) * weight;
+                       col.g += src->g * (*sub_weight) * weight;
+                       col.b += src->b * (*sub_weight) * weight;
+                       sub_weight++;           
+               } else {
+                       col.a += src->a * weight;
+                       col.r += src->r * weight;
+                       col.g += src->g * weight;
+                       col.b += src->b * weight;
+               }
+       }
+       mc->a = (int)col.a;
+       mc->r = (int)col.r;
+       mc->g = (int)col.g;
+       mc->b = (int)col.b;
+}
+static void layerInterp_mloopuv(void **sources, float *weights,
+                               float *sub_weights, int count, void *dest)
+{
+       MLoopUV *mluv = dest;
+       int i;
+       float *sub_weight;
+       struct {
+               float u;
+               float v;
+       }uv;
+       uv.u = uv.v = 0.0;
 
+       sub_weight = sub_weights;
+       for(i = 0; i < count; ++i){
+               float weight = weights ? weights[i] : 1;
+               MLoopUV *src = sources[i];
+               if(sub_weights){
+                       uv.u += src->uv[0] * (*sub_weight) * weight;
+                       uv.v += src->uv[1] * (*sub_weight) * weight;
+                       sub_weight++;           
+               } else {
+                       uv.u += src->uv[0] * weight;
+                       uv.v += src->uv[1] * weight;
+               }
+       }
+       mluv->uv[0] = uv.u;
+       mluv->uv[1] = uv.v;
+}
 
 static void layerInterp_mcol(void **sources, float *weights,
                              float *sub_weights, int count, void *dest)
@@ -432,6 +505,8 @@ static void layerDefault_mcol(void *data, int count)
                mcol[i] = default_mcol;
 }
 
+
+
 const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
        {sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL},
        {sizeof(MSticky), "MSticky", 1, NULL, NULL, NULL, layerInterp_msticky, NULL,
@@ -454,13 +529,16 @@ const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
        {sizeof(MStringProperty), "MStringProperty",1,"String",NULL,NULL,NULL,NULL},
        {sizeof(OrigSpaceFace), "OrigSpaceFace", 1, "UVTex", layerCopy_origspace_face, NULL,
         layerInterp_origspace_face, layerSwap_origspace_face, layerDefault_origspace_face},
-       {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}
+       {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
+       {sizeof(MTexPoly), "MTexPoly", 1, "Face Texture", NULL, NULL, NULL, NULL, NULL},
+       {sizeof(MLoopUV), "MLoopUV", 1, "UV coord", NULL, NULL, layerInterp_mloopuv, NULL, NULL},
+       {sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, layerInterp_mloopcol, NULL, layerDefault_mloopcol} 
 };
 
 const char *LAYERTYPENAMES[CD_NUMTYPES] = {
        "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace", "CDMTFace",
        "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags","CDMFloatProperty",
-       "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco"};
+       "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco", "CDMTexPoly", "CDMLoopUV", "CDMloopCol"};
 
 const CustomDataMask CD_MASK_BAREMESH =
        CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE;
@@ -475,6 +553,12 @@ const CustomDataMask CD_MASK_DERIVEDMESH =
        CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE |
        CD_MASK_MCOL | CD_MASK_ORIGINDEX | CD_MASK_PROP_FLT | CD_MASK_PROP_INT |
        CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORCO;
+const CustomDataMask CD_MASK_BMESH = 
+       CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR;
+const CustomDataMask CD_MASK_FACECORNERS =
+       CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
+       CD_MASK_MLOOPCOL;
+
 
 static const LayerTypeInfo *layerType_getInfo(int type)
 {
@@ -1449,6 +1533,302 @@ void CustomData_from_em_block(const CustomData *source, CustomData *dest,
 
 }
 
+/*Bmesh functions*/
+/*needed to convert to/from different face reps*/
+void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata)
+{
+       int i;
+       for(i=0; i < fdata->totlayer; i++){
+               if(fdata->layers[i].type == CD_MTFACE){
+                       CustomData_add_layer(pdata, CD_MTEXPOLY, CD_CALLOC, &(fdata->layers[i].name), 0);
+                       CustomData_add_layer(ldata, CD_MLOOPUV, CD_CALLOC, &(fdata->layers[i].name), 0);
+               }
+               else if(fdata->layers[i].type == CD_MCOL)
+                       CustomData_add_layer(ldata, CD_MLOOPCOL, CD_CALLOC, &(fdata->layers[i].name), 0);
+       }               
+}
+void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total){
+       int i;
+       for(i=0; i < pdata->totlayer; i++){
+               if(pdata->layers[i].type == CD_MTEXPOLY)
+                       CustomData_add_layer(fdata, CD_MTFACE, CD_CALLOC, &(pdata->layers[i].name), total);
+       }
+       for(i=0; i < ldata->totlayer; i++){
+               if(ldata->layers[i].type == CD_MLOOPCOL)
+                       CustomData_add_layer(fdata, CD_MCOL, CD_CALLOC, &(ldata->layers[i].name), total);
+       }
+}
+
+
+void CustomData_bmesh_init_pool(CustomData *data, int allocsize){
+       if(data->totlayer)data->pool = BLI_mempool_create(data->totsize, allocsize, allocsize);
+}
+
+void CustomData_bmesh_free_block(CustomData *data, void **block)
+{
+    const LayerTypeInfo *typeInfo;
+    int i;
+
+       if(!*block) return;
+    for(i = 0; i < data->totlayer; ++i) {
+        if(!(data->layers[i].flag & CD_FLAG_NOFREE)) {
+            typeInfo = layerType_getInfo(data->layers[i].type);
+
+            if(typeInfo->free) {
+                               int offset = data->layers[i].offset;
+                               typeInfo->free((char*)*block + offset, 1, typeInfo->size);
+                       }
+        }
+    }
+
+       BLI_mempool_free(data->pool, *block);
+       *block = NULL;
+}
+
+static void CustomData_bmesh_alloc_block(CustomData *data, void **block)
+{
+
+       if (*block)
+               CustomData_bmesh_free_block(data, block);
+
+       if (data->totsize > 0)
+               *block = BLI_mempool_calloc(data->pool);
+       else
+               *block = NULL;
+}
+
+void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest,
+                            void *src_block, void **dest_block)
+{
+       const LayerTypeInfo *typeInfo;
+       int dest_i, src_i;
+
+       if (!*dest_block)
+               CustomData_bmesh_alloc_block(dest, dest_block);
+       
+       /* copies a layer at a time */
+       dest_i = 0;
+       for(src_i = 0; src_i < source->totlayer; ++src_i) {
+
+               /* find the first dest layer with type >= the source type
+                * (this should work because layers are ordered by type)
+                */
+               while(dest_i < dest->totlayer
+                     && dest->layers[dest_i].type < source->layers[src_i].type)
+                       ++dest_i;
+
+               /* if there are no more dest layers, we're done */
+               if(dest_i >= dest->totlayer) return;
+
+               /* if we found a matching layer, copy the data */
+               if(dest->layers[dest_i].type == source->layers[src_i].type &&
+                       strcmp(dest->layers[dest_i].name, source->layers[src_i].name) == 0) {
+                       char *src_data = (char*)src_block + source->layers[src_i].offset;
+                       char *dest_data = (char*)*dest_block + dest->layers[dest_i].offset;
+
+                       typeInfo = layerType_getInfo(source->layers[src_i].type);
+
+                       if(typeInfo->copy)
+                               typeInfo->copy(src_data, dest_data, 1);
+                       else
+                               memcpy(dest_data, src_data, typeInfo->size);
+
+                       /* if there are multiple source & dest layers of the same type,
+                        * we don't want to copy all source layers to the same dest, so
+                        * increment dest_i
+                        */
+                       ++dest_i;
+               }
+       }
+}
+
+/*Bmesh Custom Data Functions. Should replace editmesh ones with these as well, due to more effecient memory alloc*/
+void *CustomData_bmesh_get(const CustomData *data, void *block, int type)
+{
+       int layer_index;
+       
+       /* get the layer index of the first layer of type */
+       layer_index = CustomData_get_active_layer_index(data, type);
+       if(layer_index < 0) return NULL;
+
+       return (char *)block + data->layers[layer_index].offset;
+}
+
+void *CustomData_bmesh_get_n(const CustomData *data, void *block, int type, int n)
+{
+       int layer_index;
+       
+       /* get the layer index of the first layer of type */
+       layer_index = CustomData_get_layer_index(data, type);
+       if(layer_index < 0) return NULL;
+
+       return (char *)block + data->layers[layer_index+n].offset;
+}
+
+void CustomData_bmesh_set(const CustomData *data, void *block, int type, void *source)
+{
+       void *dest = CustomData_bmesh_get(data, block, type);
+       const LayerTypeInfo *typeInfo = layerType_getInfo(type);
+
+       if(!dest) return;
+
+       if(typeInfo->copy)
+               typeInfo->copy(source, dest, 1);
+       else
+               memcpy(dest, source, typeInfo->size);
+}
+
+void CustomData_bmesh_set_n(CustomData *data, void *block, int type, int n, void *source)
+{
+       void *dest = CustomData_bmesh_get_n(data, block, type, n);
+       const LayerTypeInfo *typeInfo = layerType_getInfo(type);
+
+       if(!dest) return;
+
+       if(typeInfo->copy)
+               typeInfo->copy(source, dest, 1);
+       else
+               memcpy(dest, source, typeInfo->size);
+}
+
+void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights,
+                          float *sub_weights, int count, void *dest_block)
+{
+       int i, j;
+       void *source_buf[SOURCE_BUF_SIZE];
+       void **sources = source_buf;
+
+       /* slow fallback in case we're interpolating a ridiculous number of
+        * elements
+        */
+       if(count > SOURCE_BUF_SIZE)
+               sources = MEM_callocN(sizeof(*sources) * count,
+                                     "CustomData_interp sources");
+
+       /* interpolates a layer at a time */
+       for(i = 0; i < data->totlayer; ++i) {
+               CustomDataLayer *layer = &data->layers[i];
+               const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
+               if(typeInfo->interp) {
+                       for(j = 0; j < count; ++j)
+                               sources[j] = (char *)src_blocks[j] + layer->offset;
+
+                       typeInfo->interp(sources, weights, sub_weights, count,
+                                         (char *)dest_block + layer->offset);
+               }
+       }
+
+       if(count > SOURCE_BUF_SIZE) MEM_freeN(sources);
+}
+
+void CustomData_bmesh_set_default(CustomData *data, void **block)
+{
+       const LayerTypeInfo *typeInfo;
+       int i;
+
+       if (!*block)
+               CustomData_bmesh_alloc_block(data, block);
+
+       for(i = 0; i < data->totlayer; ++i) {
+               int offset = data->layers[i].offset;
+
+               typeInfo = layerType_getInfo(data->layers[i].type);
+
+               if(typeInfo->set_default)
+                       typeInfo->set_default((char*)*block + offset, 1);
+       }
+}
+
+void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
+                            int src_index, void **dest_block)
+{
+       const LayerTypeInfo *typeInfo;
+       int dest_i, src_i, src_offset;
+
+       if (!*dest_block)
+               CustomData_bmesh_alloc_block(dest, dest_block);
+       
+       /* copies a layer at a time */
+       dest_i = 0;
+       for(src_i = 0; src_i < source->totlayer; ++src_i) {
+
+               /* find the first dest layer with type >= the source type
+                * (this should work because layers are ordered by type)
+                */
+               while(dest_i < dest->totlayer
+                     && dest->layers[dest_i].type < source->layers[src_i].type)
+                       ++dest_i;
+
+               /* if there are no more dest layers, we're done */
+               if(dest_i >= dest->totlayer) return;
+
+               /* if we found a matching layer, copy the data */
+               if(dest->layers[dest_i].type == source->layers[src_i].type) {
+                       int offset = dest->layers[dest_i].offset;
+                       char *src_data = source->layers[src_i].data;
+                       char *dest_data = (char*)*dest_block + offset;
+
+                       typeInfo = layerType_getInfo(dest->layers[dest_i].type);
+                       src_offset = src_index * typeInfo->size;
+
+                       if(typeInfo->copy)
+                               typeInfo->copy(src_data + src_offset, dest_data, 1);
+                       else
+                               memcpy(dest_data, src_data + src_offset, typeInfo->size);
+
+                       /* if there are multiple source & dest layers of the same type,
+                        * we don't want to copy all source layers to the same dest, so
+                        * increment dest_i
+                        */
+                       ++dest_i;
+               }
+       }
+}
+
+void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest,
+                              void *src_block, int dest_index)
+{
+       const LayerTypeInfo *typeInfo;
+       int dest_i, src_i, dest_offset;
+
+       /* copies a layer at a time */
+       dest_i = 0;
+       for(src_i = 0; src_i < source->totlayer; ++src_i) {
+
+               /* find the first dest layer with type >= the source type
+                * (this should work because layers are ordered by type)
+                */
+               while(dest_i < dest->totlayer
+                     && dest->layers[dest_i].type < source->layers[src_i].type)
+                       ++dest_i;
+
+               /* if there are no more dest layers, we're done */
+               if(dest_i >= dest->totlayer) return;
+
+               /* if we found a matching layer, copy the data */
+               if(dest->layers[dest_i].type == source->layers[src_i].type) {
+                       int offset = source->layers[src_i].offset;
+                       char *src_data = (char*)src_block + offset;
+                       char *dest_data = dest->layers[dest_i].data;
+
+                       typeInfo = layerType_getInfo(dest->layers[dest_i].type);
+                       dest_offset = dest_index * typeInfo->size;
+
+                       if(typeInfo->copy)
+                               typeInfo->copy(src_data, dest_data + dest_offset, 1);
+                       else
+                               memcpy(dest_data + dest_offset, src_data, typeInfo->size);
+
+                       /* if there are multiple source & dest layers of the same type,
+                        * we don't want to copy all source layers to the same dest, so
+                        * increment dest_i
+                        */
+                       ++dest_i;
+               }
+       }
+
+}
+
 void CustomData_file_write_info(int type, char **structname, int *structnum)
 {
        const LayerTypeInfo *typeInfo = layerType_getInfo(type);
index b2557c9c07efb4248381d6016fa347c98183e975..b6c8ad59e0801a23a88af998612a72fb2b75d9fc 100644 (file)
@@ -848,17 +848,13 @@ void BKE_add_image_extension(char *string, int imtype)
                if(!BLI_testextensie(string, ".tga"))
                        extension= ".tga";
        }
-       else if(ELEM5(imtype, R_MOVIE, R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90)) {
-               if(!( BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg")))
-                       extension= ".jpg";
-       }
        else if(imtype==R_BMP) {
                if(!BLI_testextensie(string, ".bmp"))
                        extension= ".bmp";
        }
        else if(G.have_libtiff && (imtype==R_TIFF)) {
-               if(!BLI_testextensie(string, ".tif"))
-                       extension= ".tif";
+               if(!BLI_testextensie(string, ".tif") && 
+                       !BLI_testextensie(string, ".tiff")) extension= ".tif";
        }
 #ifdef WITH_OPENEXR
        else if( ELEM(imtype, R_OPENEXR, R_MULTILAYER)) {
@@ -874,10 +870,14 @@ void BKE_add_image_extension(char *string, int imtype)
                if (!BLI_testextensie(string, ".dpx"))
                        extension= ".dpx";
        }
-       else {  /* targa default */
+       else if(imtype==R_TARGA) {
                if(!BLI_testextensie(string, ".tga"))
                        extension= ".tga";
        }
+       else { //   R_MOVIE, R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90, R_QUICKTIME etc
+               if(!( BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg")))
+                       extension= ".jpg";
+       }
 
        strcat(string, extension);
 }
@@ -1512,6 +1512,10 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
                image_initialize_after_load(ima, ibuf);
                image_assign_ibuf(ima, ibuf, 0, frame);
 #endif
+               
+               if(ima->flag & IMA_DO_PREMUL)
+                       converttopremul(ibuf);
+               
        }
        else
                ima->ok= 0;
index 808984aaa3c985b4e88c3dfff5eaf9e8c2715987..297ac0b1530c874aa0434b6b6e7840524ab4fb7e 100644 (file)
@@ -1588,10 +1588,17 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
                                VECSUB(verts[i].tv, verts[i].tx, verts[i].txold);
                                VECCOPY(verts[i].v, verts[i].tv);
                        }
-       
+                       
                        // call collision function
-                       result = cloth_bvh_objcollision(clmd, step + dt, dt);
-       
+                       // TODO: check if "step" or "step+dt" is correct - dg
+                       result = cloth_bvh_objcollision(ob, clmd, step, dt);
+                       
+                       // correct velocity again, just to be sure we had to change it due to adaptive collisions
+                       for(i = 0; i < numverts; i++)
+                       {
+                               VECSUB(verts[i].tv, verts[i].tx, id->X[i]);
+                       }
+                       
                        // copy corrected positions back to simulation
                        for(i = 0; i < numverts; i++)
                        {               
index 321d4f1d37e0b23d53c66446a4ff5e7f2dc49706..59eb3837aab9b01b71292961c8b01eb615a77eed 100644 (file)
@@ -1859,7 +1859,7 @@ void set_icu_vars(IpoCurve *icu)
                /* yafray: aperture & focal distance params */
                switch(icu->adrcode) {
                case CAM_LENS:
-                       icu->ymin= 5.0;
+                       icu->ymin= 1.0;
                        icu->ymax= 1000.0;
                        break;
                case CAM_STA:
index 7c50b4096939d92fd810bd2b90fe9c241ed71745..c3dddf06e7c0df668276d404ef1f14323dfcb6a8 100644 (file)
@@ -224,48 +224,50 @@ void flag_all_listbases_ids(short flag, short value)
 /* note: MAX_LIBARRAY define should match this code */
 int set_listbasepointers(Main *main, ListBase **lb)
 {
+       int a = 0;
+
        /* BACKWARDS! also watch order of free-ing! (mesh<->mat) */
 
-       lb[0]= &(main->ipo);
-       lb[1]= &(main->key);
-       lb[2]= &(main->image);
-       lb[3]= &(main->tex);
-       lb[4]= &(main->mat);
-       lb[5]= &(main->vfont);
+       lb[a++]= &(main->ipo);
+       lb[a++]= &(main->key);
+       lb[a++]= &(main->nodetree);
+       lb[a++]= &(main->image);
+       lb[a++]= &(main->tex);
+       lb[a++]= &(main->mat);
+       lb[a++]= &(main->vfont);
        
        /* Important!: When adding a new object type,
         * the specific data should be inserted here 
         */
 
-       lb[6]= &(main->armature);
-       lb[7]= &(main->action);
+       lb[a++]= &(main->armature);
+       lb[a++]= &(main->action);
 
-       lb[8]= &(main->mesh);
-       lb[9]= &(main->curve);
-       lb[10]= &(main->mball);
+       lb[a++]= &(main->mesh);
+       lb[a++]= &(main->curve);
+       lb[a++]= &(main->mball);
 
-       lb[11]= &(main->wave);
-       lb[12]= &(main->latt);
-       lb[13]= &(main->lamp);
-       lb[14]= &(main->camera);
+       lb[a++]= &(main->wave);
+       lb[a++]= &(main->latt);
+       lb[a++]= &(main->lamp);
+       lb[a++]= &(main->camera);
        
-       lb[15]= &(main->text);
-       lb[16]= &(main->sound);
-       lb[17]= &(main->group);
-       lb[18]= &(main->nodetree);
-       lb[19]= &(main->brush);
-       lb[20]= &(main->script);
-       lb[21]= &(main->particle);
+       lb[a++]= &(main->text);
+       lb[a++]= &(main->sound);
+       lb[a++]= &(main->group);
+       lb[a++]= &(main->brush);
+       lb[a++]= &(main->script);
+       lb[a++]= &(main->particle);
        
-       lb[22]= &(main->world);
-       lb[23]= &(main->screen);
-       lb[24]= &(main->object);
-       lb[25]= &(main->scene);
-       lb[26]= &(main->library);
+       lb[a++]= &(main->world);
+       lb[a++]= &(main->screen);
+       lb[a++]= &(main->object);
+       lb[a++]= &(main->scene);
+       lb[a++]= &(main->library);
        
-       lb[27]= NULL;
+       lb[a]= NULL;
 
-       return 27;
+       return a;
 }
 
 /* *********** ALLOC AND FREE *****************
index a0841bb9f03907ed41d78049b95384c486dc5444..f13f8ef0298c7ccc3029e38fb43d42e36cf23895 100644 (file)
@@ -4920,7 +4920,7 @@ static void waveModifier_deformVertsEM(
 
        if(!wmd->texture && !wmd->defgrp_name[0] && !(wmd->flag & MOD_WAVE_NORM))
                dm = derivedData;
-       else if(derivedData) dm = derivedData;
+       else if(derivedData) dm = CDDM_copy(derivedData);
        else dm = CDDM_from_editmesh(editData, ob->data);
 
        if(wmd->flag & MOD_WAVE_NORM) {
index b72d9a0b044036289754e0ed4a2a1d220250e7bc..7b36e46d45e078011edac6d9c574155392bddc81 100644 (file)
@@ -732,6 +732,17 @@ void *add_lamp(char *name)
        la->preview=NULL;
        la->falloff_type = LA_FALLOFF_INVLINEAR;
        la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
+       la->sun_effect_type = 0;
+       la->horizon_brightness = 1.0;
+       la->spread = 1.0;
+       la->sun_brightness = 1.0;
+       la->sun_size = 1.0;
+       la->backscattered_light = 1.0;
+       la->atm_turbidity = 2.0;
+       la->atm_inscattering_factor = 1.0;
+       la->atm_extinction_factor = 1.0;
+       la->atm_distance_factor = 1.0;
+       la->sun_intensity = 1.0;
        curvemapping_initialize(la->curfalloff);
        return la;
 }
index 18fca5439efe4acea0a80505f1c43040601f7dca..24a3d348ae7ba6e934763da40feb05619b37bf44 100644 (file)
@@ -1371,7 +1371,7 @@ void psys_particle_on_shape(int distr, int index, float *fuv, float *vec, float
 /************************************************/
 void psys_particle_on_emitter(Object *ob, ParticleSystemModifierData *psmd, int from, int index, int index_dmcache, float *fuv, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor){
        if(psmd){
-               if(psmd->psys->part->distr==PART_DISTR_GRID){
+               if(psmd->psys->part->distr==PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT){
                        if(vec){
                                VECCOPY(vec,fuv);
                        }
index 458171cc2329cd668d67df44d67bf2bff286dc66..f70648965f413a5b9474f12cc2ae1150f1ee8c90 100644 (file)
@@ -168,7 +168,7 @@ static void realloc_particles(Object *ob, ParticleSystem *psys, int new_totpart)
        int i, totpart, totsaved = 0;
 
        if(new_totpart<0) {
-               if(psys->part->distr==PART_DISTR_GRID) {
+               if(psys->part->distr==PART_DISTR_GRID  && psys->part->from != PART_FROM_VERT) {
                        totpart= psys->part->grid_res;
                        totpart*=totpart*totpart;
                }
@@ -1056,7 +1056,7 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
                dm= CDDM_from_mesh((Mesh*)ob->data, ob);
 
                /* special handling of grid distribution */
-               if(part->distr==PART_DISTR_GRID){
+               if(part->distr==PART_DISTR_GRID && from != PART_FROM_VERT){
                        distribute_particles_in_grid(dm,psys);
                        dm->release(dm);
                        return 0;
@@ -1600,7 +1600,7 @@ void initialize_particle(ParticleData *pa, int p, Object *ob, ParticleSystem *ps
 
        NormalQuat(pa->r_rot);
 
-       if(part->distr!=PART_DISTR_GRID){
+       if(part->distr!=PART_DISTR_GRID && part->from != PART_FROM_VERT){
                /* any unique random number will do (r_ave[0]) */
                if(ptex.exist < 0.5*(1.0+pa->r_ave[0]))
                        pa->flag |= PARS_UNEXIST;
@@ -4515,7 +4515,7 @@ void psys_changed_type(ParticleSystem *psys)
        if(part->from == PART_FROM_PARTICLE) {
                if(part->type != PART_REACTOR)
                        part->from = PART_FROM_FACE;
-               if(part->distr == PART_DISTR_GRID)
+               if(part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT)
                        part->distr = PART_DISTR_JIT;
        }
 
@@ -4710,7 +4710,7 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
        oldtotpart = psys->totpart;
        oldtotchild = psys->totchild;
 
-       if(part->distr == PART_DISTR_GRID)
+       if(part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT)
                totpart = part->grid_res*part->grid_res*part->grid_res;
        else
                totpart = psys->part->totpart;
index 57ecffbb79649b20d4bf062178a5219a69cce79f..43805959e620f2a5d456c79d14dba472c5f514f9 100644 (file)
@@ -459,9 +459,10 @@ int BKE_ptcache_object_reset(Object *ob, int mode)
        PTCacheID pid;
        ParticleSystem *psys;
        ModifierData *md;
-       int reset;
+       int reset, skip;
 
        reset= 0;
+       skip= 0;
 
        if(ob->soft) {
                BKE_ptcache_id_from_softbody(&pid, ob, ob->soft);
@@ -469,11 +470,18 @@ int BKE_ptcache_object_reset(Object *ob, int mode)
        }
 
        for(psys=ob->particlesystem.first; psys; psys=psys->next) {
-               BKE_ptcache_id_from_particles(&pid, ob, psys);
-               reset |= BKE_ptcache_id_reset(&pid, mode);
-
+               /* Baked softbody hair has to be checked first, because we don't want to reset */
+               /* particles or softbody in that case -jahka */
                if(psys->soft) {
                        BKE_ptcache_id_from_softbody(&pid, ob, psys->soft);
+                       if(mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED))) 
+                               reset |= BKE_ptcache_id_reset(&pid, mode);
+                       else
+                               skip = 1;
+               }
+
+               if(skip == 0) {
+                       BKE_ptcache_id_from_particles(&pid, ob, psys);
                        reset |= BKE_ptcache_id_reset(&pid, mode);
                }
        }
index 16ca5d7542db42169204d9b9a537e333c3a03b66..fcf1c7ce311fcc3aabba5be136efe7b9e9755e41 100644 (file)
@@ -150,6 +150,9 @@ void init_sensor(bSensor *sens)
        case SENS_PROPERTY:
                sens->data= MEM_callocN(sizeof(bPropertySensor), "propsens");
                break;
+       case SENS_ACTUATOR:
+               sens->data= MEM_callocN(sizeof(bActuatorSensor), "actsens");
+               break;
        case SENS_MOUSE:
                ms=sens->data= MEM_callocN(sizeof(bMouseSensor), "mousesens");
                ms->type= LEFTMOUSE;
index 876547042dcef06c3445545e6d318b93068859d7..53b7bb975a3fac812709970cbbaf7587588dcd3e 100644 (file)
@@ -942,7 +942,8 @@ char *txt_to_buf (Text *text)
        if (!text) return NULL;
        if (!text->curl) return NULL;
        if (!text->sell) return NULL;
-               
+       if (!text->lines.first) return NULL;
+
        linef= text->lines.first;
        charf= 0;
                
index 4fa880c36d1744937f05c36d1b27ff7d2229f058..c22b6f79e08f91c86eee4054db39a96808ec6b05 100644 (file)
@@ -50,6 +50,9 @@ extern "C" {
 #ifndef M_SQRT1_2
 #define M_SQRT1_2      0.70710678118654752440
 #endif
+#ifndef M_1_PI
+#define M_1_PI         0.318309886183790671538
+#endif
 
 #ifdef WIN32
        #ifndef FREE_WINDOWS
@@ -323,6 +326,9 @@ void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb);
 void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb);
 void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr);
 void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv);
+void xyz_to_rgb(float x, float y, float z, float *r, float *g, float *b);
+int constrain_rgb(float *r, float *g, float *b);
+void gamma_correct_rgb(float *r, float *g, float *b);
 unsigned int hsv_to_cpack(float h, float s, float v);
 unsigned int rgb_to_cpack(float r, float g, float b);
 void cpack_to_rgb(unsigned int col, float *r, float *g, float *b);
diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h
new file mode 100644 (file)
index 0000000..8b31459
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * Simple fast memory allocator
+ * 
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Geoffrey Bantle.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef BLI_MEMPOOL_H
+#define BLI_MEMPOOL_H
+
+struct BLI_mempool;
+typedef struct BLI_mempool BLI_mempool;
+
+BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk);
+void *BLI_mempool_alloc(BLI_mempool *pool);
+void *BLI_mempool_calloc(BLI_mempool *pool);
+void BLI_mempool_free(BLI_mempool *pool, void *addr);
+void BLI_mempool_destroy(BLI_mempool *pool);
+
+
+#endif
index 9c192ba8b096b3fa56890bc90d9b2d8e4d696446..11150075bac763f33cf821ae51e1c96f79645212 100644 (file)
@@ -73,6 +73,9 @@
 #ifndef M_SQRT1_2
 #define M_SQRT1_2      0.70710678118654752440
 #endif
+#ifndef M_1_PI
+#define M_1_PI         0.318309886183790671538
+#endif
 
 #define MAXPATHLEN MAX_PATH
 
index a85883f65728a2000f476db0153bc48978e7cd67..a97b9ca6672bace8f7887ff6d3bfb3a9950615a4 100644 (file)
@@ -523,6 +523,7 @@ static void bvh_div_nodes(BVHTree *tree, BVHNode *node, int start, int end, char
        return;
 }
 
+#if 0
 static void verify_tree(BVHTree *tree)
 {
        int i, j, check = 0;
@@ -569,6 +570,7 @@ static void verify_tree(BVHTree *tree)
        
        printf("branches: %d, leafs: %d, total: %d\n", tree->totbranch, tree->totleaf, tree->totbranch + tree->totleaf);
 }
+#endif
        
 void BLI_bvhtree_balance(BVHTree *tree)
 {
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
new file mode 100644 (file)
index 0000000..7ac7b8b
--- /dev/null
@@ -0,0 +1,140 @@
+/**
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 by Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/*
+       Simple, fast memory allocator for allocating many elements of the same size.
+*/
+
+#include "MEM_guardedalloc.h"
+#include "BLI_blenlib.h"
+#include "DNA_listBase.h"
+#include "BLI_linklist.h"
+#include <string.h> 
+
+typedef struct BLI_freenode{
+       struct BLI_freenode *next;
+}BLI_freenode;
+
+typedef struct BLI_mempool_chunk{
+       struct BLI_mempool_chunk *next, *prev;
+       void *data;
+}BLI_mempool_chunk;
+
+typedef struct BLI_mempool{
+       struct ListBase chunks;
+       int esize, csize, pchunk;               /*size of elements and chunks in bytes and number of elements per chunk*/
+       struct BLI_freenode     *free;          /*free element list. Interleaved into chunk datas.*/
+}BLI_mempool;
+
+BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk)
+{      BLI_mempool  *pool = NULL;
+       BLI_freenode *lasttail = NULL, *curnode = NULL;
+       int i,j, maxchunks;
+       char *addr;
+
+       /*allocate the pool structure*/
+       pool = MEM_mallocN(sizeof(BLI_mempool),"memory pool");
+       pool->esize = esize;
+       pool->pchunk = pchunk;  
+       pool->csize = esize * pchunk;
+       pool->chunks.first = pool->chunks.last = NULL;
+       
+       maxchunks = tote / pchunk;
+       
+       /*allocate the actual chunks*/
+       for(i=0; i < maxchunks; i++){
+               BLI_mempool_chunk *mpchunk = MEM_mallocN(sizeof(BLI_mempool_chunk), "BLI_Mempool Chunk");
+               mpchunk->next = mpchunk->prev = NULL;
+               mpchunk->data = MEM_mallocN(pool->csize, "BLI Mempool Chunk Data");
+               BLI_addtail(&(pool->chunks), mpchunk);
+               
+               if(i==0) pool->free = mpchunk->data; /*start of the list*/
+               /*loop through the allocated data, building the pointer structures*/
+               for(addr = mpchunk->data, j=0; j < pool->pchunk; j++){
+                       curnode = ((BLI_freenode*)addr);
+                       addr += pool->esize;
+                       curnode->next = (BLI_freenode*)addr;
+               }
+               /*final pointer in the previously allocated chunk is wrong.*/
+               if(lasttail) lasttail->next = mpchunk->data;
+               /*set the end of this chunks memoryy to the new tail for next iteration*/
+               lasttail = curnode;
+       }
+       /*terminate the list*/
+       curnode->next = NULL;
+       return pool;
+}
+void *BLI_mempool_alloc(BLI_mempool *pool){
+       void *retval=NULL;
+       BLI_freenode *curnode=NULL;
+       char *addr=NULL;
+       int j;
+
+       if(!(pool->free)){
+               /*need to allocate a new chunk*/
+               BLI_mempool_chunk *mpchunk = MEM_mallocN(sizeof(BLI_mempool_chunk), "BLI_Mempool Chunk");
+               mpchunk->next = mpchunk->prev = NULL;
+               mpchunk->data = MEM_mallocN(pool->csize, "BLI_Mempool Chunk Data");
+               BLI_addtail(&(pool->chunks), mpchunk);
+
+               pool->free = mpchunk->data; /*start of the list*/
+               for(addr = mpchunk->data, j=0; j < pool->pchunk; j++){
+                       curnode = ((BLI_freenode*)addr);
+                       addr += pool->esize;
+                       curnode->next = (BLI_freenode*)addr;
+               }
+               curnode->next = NULL; /*terminate the list*/
+       }
+
+       retval = pool->free;
+       pool->free = pool->free->next;
+       //memset(retval, 0, pool->esize);
+       return retval;
+}
+
+void *BLI_mempool_calloc(BLI_mempool *pool){
+       void *retval=NULL;
+       retval = BLI_mempool_alloc(pool);
+       memset(retval, 0, pool->esize);
+       return retval;
+}
+
+
+
+void BLI_mempool_free(BLI_mempool *pool, void *addr){ //doesnt protect against double frees, dont be stupid!
+       BLI_freenode *newhead = addr;
+       newhead->next = pool->free;
+       pool->free = newhead;
+}
+void BLI_mempool_destroy(BLI_mempool *pool)
+{
+       BLI_mempool_chunk *mpchunk=NULL;
+       for(mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) MEM_freeN(mpchunk->data);
+       BLI_freelistN(&(pool->chunks));
+       MEM_freeN(pool);
+}
index 2084ab3da5faf5c438b9834cb7d0a96bfe75ae40..c97ca3c6a8abd93c27fa6fab9d58cf60ffa52ac9 100644 (file)
@@ -3414,6 +3414,66 @@ void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv)
        *lv = v;
 }
 
+/*http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
+ * SMPTE-C XYZ to RGB matrix*/
+void xyz_to_rgb(float xc, float yc, float zc, float *r, float *g, float *b)
+{
+       *r = (3.50570   * xc) + (-1.73964       * yc) + (-0.544011      * zc);
+       *g = (-1.06906  * xc) + (1.97781        * yc) + (0.0351720      * zc);
+       *b = (0.0563117 * xc) + (-0.196994      * yc) + (1.05005        * zc);
+}
+
+/*If the requested RGB shade contains a negative weight for
+  one of the primaries, it lies outside the colour gamut 
+  accessible from the given triple of primaries.  Desaturate
+  it by adding white, equal quantities of R, G, and B, enough
+  to make RGB all positive.  The function returns 1 if the
+  components were modified, zero otherwise.*/
+int constrain_rgb(float *r, float *g, float *b)
+{
+       float w;
+
+    /* Amount of white needed is w = - min(0, *r, *g, *b) */
+    
+    w = (0 < *r) ? 0 : *r;
+    w = (w < *g) ? w : *g;
+    w = (w < *b) ? w : *b;
+    w = -w;
+
+    /* Add just enough white to make r, g, b all positive. */
+    
+    if (w > 0) {
+        *r += w;  *g += w; *b += w;
+        return 1;                     /* Colour modified to fit RGB gamut */
+    }
+
+    return 0;                         /* Colour within RGB gamut */
+}
+
+/*Transform linear RGB values to nonlinear RGB values. Rec.
+  709 is ITU-R Recommendation BT. 709 (1990) ``Basic
+  Parameter Values for the HDTV Standard for the Studio and
+  for International Programme Exchange'', formerly CCIR Rec.
+  709.*/
+void gamma_correct(float *c)
+{
+       /* Rec. 709 gamma correction. */
+       float cc = 0.018;
+       
+       if (*c < cc) {
+           *c *= ((1.099 * pow(cc, 0.45)) - 0.099) / cc;
+       } else {
+           *c = (1.099 * pow(*c, 0.45)) - 0.099;
+       }
+}
+
+void gamma_correct_rgb(float *r, float *g, float *b)
+{
+    gamma_correct(r);
+    gamma_correct(g);
+    gamma_correct(b);
+}
+
 
 /* we define a 'cpack' here as a (3 byte color code) number that can be expressed like 0xFFAA66 or so.
    for that reason it is sensitive for endianness... with this function it works correctly
index 5a85fbfc37500341c4295ec72ecf6dfc414bedcf..48ebf770e1bcd428917af994032608de33039321 100644 (file)
@@ -1722,6 +1722,7 @@ void BLI_where_am_i(char *fullname, const char *name)
        path = br_find_exe( NULL );
        if (path) {
                strcpy(fullname, path);
+               free(path);
                return;
        }
 #endif
index 9cfce5e34fa02a0d6298fa6fa79eeeca004b93d6..3c629818b2dd0204fe899b1804aeeebd584ae36d 100644 (file)
@@ -7646,6 +7646,23 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
+       /* sun/sky */
+       if ((main->versionfile < 246) ){
+               Lamp *la;
+               for(la=main->lamp.first; la; la= la->id.next) {
+                       la->sun_effect_type = 0;
+                       la->horizon_brightness = 1.0;
+                       la->spread = 1.0;
+                       la->sun_brightness = 1.0;
+                       la->sun_size = 1.0;
+                       la->backscattered_light = 1.0;
+                       la->atm_turbidity = 2.0;
+                       la->atm_inscattering_factor = 1.0;
+                       la->atm_extinction_factor = 1.0;
+                       la->atm_distance_factor = 1.0;
+                       la->sun_intensity = 1.0;
+               }
+       }
 
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
index 9f28e13ff7b9d7991f085accc015dc7e76e91f7e..ca91f1dc3461f7bcd4dc7d33737cde89f0d786ea 100644 (file)
@@ -603,6 +603,9 @@ static void write_sensors(WriteData *wd, ListBase *lb)
                case SENS_PROPERTY:
                        writestruct(wd, DATA, "bPropertySensor", 1, sens->data);
                        break;
+               case SENS_ACTUATOR:
+                       writestruct(wd, DATA, "bActuatorSensor", 1, sens->data);
+                       break;
                case SENS_COLLISION:
                        writestruct(wd, DATA, "bCollisionSensor", 1, sens->data);
                        break;
index 71d3594983329ac3cb0515c9ee1615d0abb1cced..7dc1f966b71b950edb40ac60c6abb97066c6b9c3 100644 (file)
@@ -183,8 +183,9 @@ struct anim {
        AVFormatContext *pFormatCtx;
        AVCodecContext *pCodecCtx;
        AVCodec *pCodec;
-       AVFrame *pFrameRGB;
        AVFrame *pFrame;
+       AVFrame *pFrameRGB;
+       AVFrame *pFrameDeinterlaced;
        struct SwsContext *img_convert_ctx;
        int videoStream;
 #endif
index 7fc8145c4a7d7e5730837e80c768dd213e9f8ea3..720f5b0f7c8d0bc967424642274a1af88d33c5fd 100644 (file)
@@ -600,6 +600,7 @@ static int startffmpeg(struct anim * anim) {
        anim->videoStream = videoStream;
 
        anim->pFrame = avcodec_alloc_frame();
+       anim->pFrameDeinterlaced = avcodec_alloc_frame();
        anim->pFrameRGB = avcodec_alloc_frame();
 
        if (avpicture_get_size(PIX_FMT_BGR32, anim->x, anim->y)
@@ -609,10 +610,20 @@ static int startffmpeg(struct anim * anim) {
                avcodec_close(anim->pCodecCtx);
                av_close_input_file(anim->pFormatCtx);
                av_free(anim->pFrameRGB);
+               av_free(anim->pFrameDeinterlaced);
                av_free(anim->pFrame);
                return -1;
        }
 
+       if (anim->ib_flags & IB_animdeinterlace) {
+               avpicture_fill((AVPicture*) anim->pFrameDeinterlaced, 
+                              MEM_callocN(avpicture_get_size(
+                                                  anim->pCodecCtx->pix_fmt,
+                                                  anim->x, anim->y), 
+                                          "ffmpeg deinterlace"), 
+                              anim->pCodecCtx->pix_fmt, anim->x, anim->y);
+       }
+
        if (pCodecCtx->has_b_frames) {
                anim->preseek = 25; /* FIXME: detect gopsize ... */
        } else {
@@ -644,7 +655,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
 
        ibuf = IMB_allocImBuf(anim->x, anim->y, 24, IB_rect, 0);
 
-       avpicture_fill((AVPicture *)anim->pFrameRGB, 
+       avpicture_fill((AVPicture*) anim->pFrameRGB, 
                       (unsigned char*) ibuf->rect, 
                       PIX_FMT_BGR32, anim->x, anim->y);
 
@@ -723,15 +734,29 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
                        } 
 
                        if(frameFinished && pos_found == 1) {
+                               AVFrame * input = anim->pFrame;
+
+                               /* This means the data wasnt read properly, 
+                                  this check stops crashing */
+                               if (input->data[0]==0 && input->data[1]==0 
+                                   && input->data[2]==0 && input->data[3]==0){
+                                       av_free_packet(&packet);
+                                       break;
+                               }
+
                                if (anim->ib_flags & IB_animdeinterlace) {
                                        if (avpicture_deinterlace(
-                                                   anim->pFrame,
+                                                   (AVPicture*) 
+                                                   anim->pFrameDeinterlaced,
+                                                   (const AVPicture*)
                                                    anim->pFrame,
                                                    anim->pCodecCtx->pix_fmt,
                                                    anim->pCodecCtx->width,
                                                    anim->pCodecCtx->height)
                                            < 0) {
                                                filter_y = 1;
+                                       } else {
+                                               input = anim->pFrameDeinterlaced;
                                        }
                                }
 
@@ -748,8 +773,8 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
                                        unsigned char* top;
 
                                        sws_scale(anim->img_convert_ctx,
-                                                 anim->pFrame->data,
-                                                 anim->pFrame->linesize,
+                                                 input->data,
+                                                 input->linesize,
                                                  0,
                                                  anim->pCodecCtx->height,
                                                  dst2,
@@ -806,27 +831,25 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
                                        int i;
                                        unsigned char* r;
                                        
-                                       /* This means the data wasnt read properly, this check stops crashing */
-                                       if (anim->pFrame->data[0]!=0 || anim->pFrame->data[1]!=0 || anim->pFrame->data[2]!=0 || anim->pFrame->data[3]!=0) {
                                                
-                                               sws_scale(anim->img_convert_ctx,
-                                                         anim->pFrame->data,
-                                                         anim->pFrame->linesize,
-                                                         0,
-                                                         anim->pCodecCtx->height,
-                                                         dst2,
-                                                         dstStride2);
+                                       sws_scale(anim->img_convert_ctx,
+                                                 input->data,
+                                                 input->linesize,
+                                                 0,
+                                                 anim->pCodecCtx->height,
+                                                 dst2,
+                                                 dstStride2);
                                        
-                                               /* workaround: sws_scale 
-                                                  sets alpha = 0... */
+                                       /* workaround: sws_scale 
+                                          sets alpha = 0... */
                                        
-                                               r = (unsigned char*) ibuf->rect;
-       
-                                               for (i = 0; i < ibuf->x * ibuf->y;i++){
-                                                       r[3] = 0xff;
-                                                       r+=4;
-                                               }
+                                       r = (unsigned char*) ibuf->rect;
+                                       
+                                       for (i = 0; i < ibuf->x * ibuf->y;i++){
+                                               r[3] = 0xff;
+                                               r+=4;
                                        }
+                                       
                                        av_free_packet(&packet);
                                        break;
                                }
@@ -851,6 +874,11 @@ static void free_anim_ffmpeg(struct anim * anim) {
                av_close_input_file(anim->pFormatCtx);
                av_free(anim->pFrameRGB);
                av_free(anim->pFrame);
+
+               if (anim->ib_flags & IB_animdeinterlace) {
+                       MEM_freeN(anim->pFrameDeinterlaced->data[0]);
+               }
+               av_free(anim->pFrameDeinterlaced);
                sws_freeContext(anim->img_convert_ctx);
        }
        anim->duration = 0;
index b59908fef39715c2c2fea2e78e823bf3eab76649..3e618a483e352ca8b8ebf981b5de9cd84035d941 100644 (file)
@@ -451,7 +451,7 @@ void IMB_exr_begin_write(void *handle, char *filename, int width, int height, in
        openexr_header_compression(&header, compress);
        /* header.lineOrder() = DECREASING_Y; this crashes in windows for file read! */
        
-       header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.43"));
+       header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.43 and newer"));
        
        data->ofile = new OutputFile(filename, header);
 }
@@ -842,7 +842,7 @@ typedef struct RGBA
 } RGBA;
 
 
-#if 0
+/* debug only */
 static void exr_print_filecontents(InputFile *file)
 {
        const ChannelList &channels = file->header().channels();
@@ -853,7 +853,27 @@ static void exr_print_filecontents(InputFile *file)
                printf("OpenEXR-load: Found channel %s of type %d\n", i.name(), channel.type);
        }
 }
-#endif
+
+/* for non-multilayer, map  R G B A channel names to something that's in this file */
+static const char *exr_rgba_channelname(InputFile *file, const char *chan)
+{
+       const ChannelList &channels = file->header().channels();
+       
+       for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i)
+       {
+               const Channel &channel = i.channel();
+               const char *str= i.name();
+               int len= strlen(str);
+               if(len) {
+                       if(BLI_strcasecmp(chan, str+len-1)==0) {
+                               return str;
+                       }
+               }
+       }
+       return chan;
+}
+
+
 
 static int exr_has_zbuffer(InputFile *file)
 {
@@ -896,7 +916,8 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
                //printf("OpenEXR-load: image data window %d %d %d %d\n", 
                //         dw.min.x, dw.min.y, dw.max.x, dw.max.y);
 
-               // exr_print_filecontents(file);
+               if(0) // debug
+                       exr_print_filecontents(file);
                
                is_multi= exr_is_renderresult(file);
                
@@ -935,11 +956,15 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
                                        /* but, since we read y-flipped (negative y stride) we move to last scanline */
                                        first+= 4*(height-1)*width;
                                        
-                                       frameBuffer.insert ("R", Slice (FLOAT,  (char *) first, xstride, ystride));
-                                       frameBuffer.insert ("G", Slice (FLOAT,  (char *) (first+1), xstride, ystride));
-                                       frameBuffer.insert ("B", Slice (FLOAT,  (char *) (first+2), xstride, ystride));
-                                                                                                                                                       /* 1.0 is fill value */
-                                       frameBuffer.insert ("A", Slice (FLOAT,  (char *) (first+3), xstride, ystride, 1, 1, 1.0f));
+                                       frameBuffer.insert ( exr_rgba_channelname(file, "R"), 
+                                                                               Slice (FLOAT,  (char *) first, xstride, ystride));
+                                       frameBuffer.insert ( exr_rgba_channelname(file, "G"), 
+                                                                               Slice (FLOAT,  (char *) (first+1), xstride, ystride));
+                                       frameBuffer.insert ( exr_rgba_channelname(file, "B"), 
+                                                                               Slice (FLOAT,  (char *) (first+2), xstride, ystride));
+                                                                                                                                                       
+                                       frameBuffer.insert ( exr_rgba_channelname(file, "A"), 
+                                                                               Slice (FLOAT,  (char *) (first+3), xstride, ystride, 1, 1, 1.0f)); /* 1.0 is fill value */
 
                                        if(exr_has_zbuffer(file)) 
                                        {
index 3f9a6e438ccadb4801c762170450ffd3cf2abef8..de28db64c3b11a6fdca418da0a5ba32004e5f740 100644 (file)
@@ -63,6 +63,7 @@ void get_local_bounds(struct Object *ob, float *center, float *size);
 /* drawing flags: */
 #define DRAW_PICKING   1
 #define DRAW_CONSTCOLOR        2
+#define DRAW_SCENESET  4
 void draw_object(struct Base *base, int flag);
 void drawaxes(float size, int flag, char drawtype);
 
index 2d751f56fc5b18f732961a16d05e7bc0e31bbf3d..7e0f703681b4aec57c1a7b34323d450aa8c2e7dd 100644 (file)
@@ -141,6 +141,7 @@ void paste_actdata(void);
 /* Group/Channel Operations */
 struct bActionGroup *get_active_actiongroup(struct bAction *act);
 void set_active_actiongroup(struct bAction *act, struct bActionGroup *agrp, short select);
+void actionbone_group_copycolors(struct bActionGroup *grp, short init_new);
 void verify_pchan2achan_grouping(struct bAction *act, struct bPose *pose, char name[]);
 void sync_pchan2achan_grouping(void); 
 void action_groups_group(short add_group);
@@ -166,6 +167,7 @@ void deselect_action_channels(short mode);
 void deselect_actionchannels(struct bAction *act, short mode);
 int select_channel(struct bAction *act, struct bActionChannel *achan, int selectmode);
 void select_actionchannel_by_name(struct bAction *act, char *name, int select);
+void select_action_group_channels(struct bAction *act, struct bActionGroup *agrp);
 void selectkeys_leftright (short leftright, short select_mode);
 
 /* Action Markers */
index 5ed024719788b175e12ed138d6f8006badf72da2..c3660f700b3a9d62ca748d6a349f7a1e6b5ce61b 100644 (file)
@@ -82,7 +82,7 @@ void  clear_armature(struct Object *ob, char mode);
 void   delete_armature(void);
 void   deselectall_armature(int toggle, int doundo);
 void   deselectall_posearmature (struct Object *ob, int test, int doundo);
-int            draw_armature(struct Base *base, int dt);
+int            draw_armature(struct Base *base, int dt, int flag);
 
 void   extrude_armature(int forked);
 void   subdivide_armature(int numcuts);
index e6cbe7bb69aa1aa02fcfa2c6a03eb2fbc2df60c3..df514190270acb8b7d95e9aac3ecb5fec1be0f62 100644 (file)
@@ -591,6 +591,9 @@ void        BIF_load_ui_colors              (void);
 char   *BIF_ThemeGetColorPtr(struct bTheme *btheme, int spacetype, int colorid);
 char   *BIF_ThemeColorsPup(int spacetype);
 
+/* only for Bone Color sets */
+char *BIF_ThemeColorSetsPup(short inc_custom);
+
 
 void   BIF_def_color                   (BIFColorID colorid, unsigned char r, unsigned char g, unsigned char b);
 
index 15a9218b73573778b7878663308a3adfbfd9b884..0d96de7be6035db7f3aa2f25e0830a56b9cc100a 100644 (file)
@@ -92,6 +92,8 @@ void update_changed_seq_and_deps(struct Sequence *seq, int len_change, int ibuf_
 struct RenderResult;
 void do_render_seq(struct RenderResult *rr, int cfra);
 
+int seq_can_blend(struct Sequence *seq);
+
 #define SEQ_HAS_PATH(seq) (seq->type==SEQ_MOVIE || seq->type==SEQ_HD_SOUND || seq->type==SEQ_RAM_SOUND || seq->type==SEQ_IMAGE)
 
 #endif
index a798224b35b4b20694c3ae08f6bad7e443774c92..6f8b94d7cd177a4be1c4f4226b111ba89ae96c25 100644 (file)
 #define B_ACTCOPYKEYS          710
 #define B_ACTPASTEKEYS         711
 
+#define B_ACTCUSTCOLORS                712
+#define B_ACTCOLSSELECTOR      713
+#define B_ACTGRP_SELALL                714
+#define B_ACTGRP_ADDTOSELF     715
+#define B_ACTGRP_UNGROUP       716
+
 /* TIME: 751 - 800 */
 #define B_TL_REW               751
 #define B_TL_PLAY              752
index 70d603a6ed950d8210b594ecb4e601beed9c5c65..ac9761f165df751684a088809f128ad20126ddb4 100644 (file)
@@ -51,8 +51,9 @@ typedef struct bActionActuator {
        int     sta, end;               /* Start & End frames */                        
        char    name[32];               /* For property-driven playback */      
        char    frameProp[32];  /* Set this property to the actions current frame */
-       int     blendin;                /* Number of frames of blending */      
-       short   priority;               /* Execution priority */                        
+       short   blendin;                /* Number of frames of blending */
+       short   priority;               /* Execution priority */
+       short   end_reset;      /* Ending the actuator (negative pulse) wont reset the the action to its starting frame */
        short   strideaxis;             /* Displacement axis */
        float   stridelength;   /* Displacement incurred by cycle */
 } bActionActuator;                                                                                             
@@ -81,7 +82,7 @@ typedef struct bEditObjectActuator {
        char name[32];
        float linVelocity[3]; /* initial lin. velocity on creation */
        short localflag; /* flag for the lin. vel: apply locally   */
-       short pad;
+       short dyn_operation;
 } bEditObjectActuator;
 
 typedef struct bSceneActuator {
@@ -98,7 +99,8 @@ typedef struct bPropertyActuator {
 } bPropertyActuator;
 
 typedef struct bObjectActuator {
-       int flag, type;
+       short flag, type, otype;
+       short damping;
        float forceloc[3], forcerot[3];
        float loc[3], rot[3];
        float dloc[3], drot[3];
@@ -123,10 +125,13 @@ typedef struct bCameraActuator {
 } bCameraActuator ;
 
 typedef struct bConstraintActuator {
+       short type, mode;
        short flag, damp;
-       float slow;
+       short time, rotdamp;
+       int pad;
        float minloc[3], maxloc[3];
        float minrot[3], maxrot[3];
+       char matprop[32];
 } bConstraintActuator;
 
 typedef struct bGroupActuator {
@@ -192,10 +197,10 @@ typedef struct bVisibilityActuator {
 
 typedef struct bTwoDFilterActuator{
        char pad[4];
-       /* Tells what type of 2D Filter*/
+       /* Tells what type of 2D Filter */
        short type;
        /* (flag == 0) means 2D filter is activate and
-          (flag != 0) means 2D filter is inactive*/
+          (flag != 0) means 2D filter is inactive */
        short flag;
        int   int_arg;
        /* a float argument */
@@ -246,19 +251,19 @@ typedef struct FreeCamera {
 /* objectactuator->flag */
 #define ACT_FORCE_LOCAL                        1
 #define ACT_TORQUE_LOCAL               2
+#define ACT_SERVO_LIMIT_X              2
 #define ACT_DLOC_LOCAL                 4
+#define ACT_SERVO_LIMIT_Y              4
 #define ACT_DROT_LOCAL                 8
+#define ACT_SERVO_LIMIT_Z              8
 #define ACT_LIN_VEL_LOCAL              16
 #define ACT_ANG_VEL_LOCAL              32
 //#define ACT_ADD_LIN_VEL_LOCAL        64
 #define ACT_ADD_LIN_VEL                        64
 
-#define ACT_OBJECT_FORCE       0
-#define ACT_OBJECT_TORQUE      1
-#define ACT_OBJECT_DLOC                2
-#define ACT_OBJECT_DROT                3
-#define ACT_OBJECT_LINV                4
-#define ACT_OBJECT_ANGV                5
+/* objectactuator->type */
+#define ACT_OBJECT_NORMAL      0
+#define ACT_OBJECT_SERVO       1
 
 /* actuator->type */
 #define ACT_OBJECT             0
@@ -333,8 +338,9 @@ typedef struct FreeCamera {
 /* ipoactuator->flag */
 #define ACT_IPOFORCE        (1 << 0)
 #define ACT_IPOEND          (1 << 1)
-#define ACT_IPOFORCE_LOCAL  (1 << 2)
-#define ACT_IPOCHILD        (1 << 4)                   
+#define ACT_IPOLOCAL           (1 << 2)
+#define ACT_IPOCHILD        (1 << 4)   
+#define ACT_IPOADD                     (1 << 5)
 
 /* ipoactuator->flag for k2k */
 #define ACT_K2K_PREV           1
@@ -354,14 +360,31 @@ typedef struct FreeCamera {
 #define ACT_CONST_ROTX         8
 #define ACT_CONST_ROTY         16
 #define ACT_CONST_ROTZ         32
+#define ACT_CONST_NORMAL       64
+#define ACT_CONST_MATERIAL     128
+#define ACT_CONST_PERMANENT 256
+#define ACT_CONST_DISTANCE     512
+/* constraint mode */
+#define ACT_CONST_DIRPX                1
+#define ACT_CONST_DIRPY                2
+#define ACT_CONST_DIRPZ                4
+#define ACT_CONST_DIRMX                8
+#define ACT_CONST_DIRMY                16
+#define ACT_CONST_DIRMZ                32
+
+/* constraint type */
+#define ACT_CONST_TYPE_LOC     0
+#define ACT_CONST_TYPE_DIST    1
+#define ACT_CONST_TYPE_ORI     2
 
 /* editObjectActuator->type */
 #define ACT_EDOB_ADD_OBJECT            0
 #define ACT_EDOB_END_OBJECT            1
-#define ACT_EDOB_REPLACE_MESH  2
+#define ACT_EDOB_REPLACE_MESH          2
 #define ACT_EDOB_TRACK_TO              3
-#define ACT_EDOB_MAKE_CHILD            4
-#define ACT_EDOB_END_CHILD             5
+#define ACT_EDOB_DYNAMICS              4
+
+
 
 /* editObjectActuator->flag */
 #define ACT_TRACK_3D                   1
index cc9215e7d14a42fcc7de3c60c68380c9e7dd8c84..376f95b0145147d9a8f59dc0419a4c2ef03fa544 100644 (file)
@@ -66,6