Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-12-27 15:05:49 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-12-27 15:05:49 +0400
commit76b562237f31a804cd2eba9e3af6effa54f31b5b (patch)
treed789e373995ad0ab4ca0fb5668937c5b7814bb2d
parent03e388127034c35c82ed0f84b2239125111db5a4 (diff)
parentd09a8ea9e7a8ad208326b99a0631e9efc7119fbd (diff)
Merge branch 'master' into soc-2013-depsgraph_mtsoc-2013-depsgraph_mt
Conflicts: source/blender/blenkernel/intern/constraint.c source/blender/blenkernel/intern/depsgraph.c source/blender/blenkernel/intern/object.c source/blender/blenkernel/intern/scene.c source/blender/blenkernel/intern/shrinkwrap.c source/blender/collada/AnimationExporter.cpp source/blender/editors/space_image/image_ops.c source/blender/editors/space_view3d/view3d_view.c source/blender/makesrna/intern/rna_scene.c source/blender/modifiers/intern/MOD_util.c source/blender/render/intern/source/pipeline.c
-rw-r--r--.arcconfig2
-rw-r--r--CMakeLists.txt17
-rw-r--r--doc/python_api/rst/info_tips_and_tricks.rst2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp1
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h1
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp16
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h7
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h3
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp149
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h5
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp34
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h11
-rw-r--r--extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp28
-rw-r--r--extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h10
-rw-r--r--extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h6
-rw-r--r--extern/bullet2/src/BulletSoftBody/btSoftBody.cpp3
-rw-r--r--extern/bullet2/src/LinearMath/btMatrixX.h443
-rw-r--r--extern/bullet2/src/LinearMath/btScalar.h11
-rw-r--r--extern/bullet2/src/LinearMath/btVector3.cpp8
-rw-r--r--extern/bullet2/src/LinearMath/btVector3.h17
-rw-r--r--intern/cycles/blender/addon/ui.py11
-rw-r--r--intern/cycles/blender/blender_curves.cpp10
-rw-r--r--intern/cycles/device/device_opencl.cpp2
-rw-r--r--intern/cycles/kernel/kernel_bvh.h39
-rw-r--r--intern/cycles/kernel/kernel_types.h3
-rw-r--r--intern/cycles/render/curves.cpp4
-rw-r--r--intern/cycles/render/curves.h1
-rw-r--r--intern/rigidbody/RBI_api.h175
-rw-r--r--intern/rigidbody/rb_bullet_api.cpp125
m---------release/scripts/addons0
m---------release/scripts/addons_contrib0
-rw-r--r--release/scripts/startup/bl_operators/object.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_rigidbody.py6
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py3
-rw-r--r--release/scripts/startup/bl_ui/space_info.py14
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h2
-rw-r--r--source/blender/blenkernel/BKE_action.h3
-rw-r--r--source/blender/blenkernel/BKE_cdderivedmesh.h2
-rw-r--r--source/blender/blenkernel/BKE_library.h1
-rw-r--r--source/blender/blenkernel/BKE_object.h1
-rw-r--r--source/blender/blenkernel/BKE_rigidbody.h5
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c16
-rw-r--r--source/blender/blenkernel/intern/action.c29
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c4
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c15
-rw-r--r--source/blender/blenkernel/intern/library.c79
-rw-r--r--source/blender/blenkernel/intern/multires.c14
-rw-r--r--source/blender/blenkernel/intern/node.c7
-rw-r--r--source/blender/blenkernel/intern/object.c9
-rw-r--r--source/blender/blenkernel/intern/particle_system.c4
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c120
-rw-r--r--source/blender/blenkernel/intern/scene.c2
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c2
-rw-r--r--source/blender/blenlib/intern/math_geom.c20
-rw-r--r--source/blender/blenlib/intern/polyfill2d.c26
-rw-r--r--source/blender/blenlib/intern/string.c4
-rw-r--r--source/blender/blenloader/intern/readfile.c10
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c19
-rw-r--r--source/blender/bmesh/intern/bmesh_core.h13
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c117
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.h6
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c50
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c31
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.h3
-rw-r--r--source/blender/bmesh/intern/bmesh_queries_inline.h9
-rw-r--r--source/blender/bmesh/operators/bmo_connect.c14
-rw-r--r--source/blender/bmesh/operators/bmo_connect_nonplanar.c17
-rw-r--r--source/blender/bmesh/operators/bmo_dissolve.c2
-rw-r--r--source/blender/bmesh/operators/bmo_removedoubles.c32
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c25
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide_edgering.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c4
-rw-r--r--source/blender/bmesh/tools/bmesh_bisect_plane.c11
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_collapse.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c2
-rw-r--r--source/blender/collada/AnimationExporter.cpp2
-rw-r--r--source/blender/collada/collada_utils.cpp2
-rw-r--r--source/blender/editors/animation/anim_filter.c18
-rw-r--r--source/blender/editors/include/BIF_glutil.h1
-rw-r--r--source/blender/editors/include/ED_anim_api.h5
-rw-r--r--source/blender/editors/include/UI_interface.h8
-rw-r--r--source/blender/editors/interface/interface_draw.c6
-rw-r--r--source/blender/editors/interface/interface_intern.h5
-rw-r--r--source/blender/editors/interface/interface_widgets.c18
-rw-r--r--source/blender/editors/mask/mask_draw.c3
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c41
-rw-r--r--source/blender/editors/object/object_bake.c4
-rw-r--r--source/blender/editors/screen/glutil.c22
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c113
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c22
-rw-r--r--source/blender/editors/space_clip/clip_intern.h4
-rw-r--r--source/blender/editors/space_clip/clip_utils.c8
-rw-r--r--source/blender/editors/space_clip/space_clip.c2
-rw-r--r--source/blender/editors/space_image/image_draw.c82
-rw-r--r--source/blender/editors/space_info/info_intern.h1
-rw-r--r--source/blender/editors/space_info/info_ops.c38
-rw-r--r--source/blender/editors/space_info/space_info.c1
-rw-r--r--source/blender/editors/space_view3d/drawobject.c92
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c2
-rw-r--r--source/blender/editors/transform/transform_conversions.c4
-rw-r--r--source/blender/editors/util/crazyspace.c2
-rw-r--r--source/blender/imbuf/intern/colormanagement.c95
-rw-r--r--source/blender/imbuf/intern/imageprocess.c50
-rw-r--r--source/blender/makesdna/DNA_rigidbody_types.h16
-rw-r--r--source/blender/makesdna/DNA_space_types.h43
-rw-r--r--source/blender/makesdna/intern/makesdna.c4
-rw-r--r--source/blender/makesrna/intern/rna_main.c20
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c2
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_rigidbody.c19
-rw-r--r--source/blender/makesrna/intern/rna_space.c15
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c2
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c2
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c62
-rw-r--r--source/blender/modifiers/intern/MOD_util.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c2
-rw-r--r--source/blender/modifiers/intern/MOD_wireframe.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_utils.c12
-rw-r--r--source/blender/python/generic/bpy_threads.c8
-rw-r--r--source/blender/render/intern/source/pipeline.c2
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp11
-rw-r--r--source/gameengine/Converter/BlenderWorldInfo.cpp75
-rw-r--r--source/gameengine/Converter/BlenderWorldInfo.h78
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.h49
-rw-r--r--source/gameengine/Ketsji/KX_WorldInfo.h42
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp2
-rw-r--r--source/gameengine/Rasterizer/RAS_IRasterizer.h354
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp27
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h404
130 files changed, 2112 insertions, 1701 deletions
diff --git a/.arcconfig b/.arcconfig
index 57f6c39f1ea..8fc370a94ac 100644
--- a/.arcconfig
+++ b/.arcconfig
@@ -1,6 +1,6 @@
{
"project_id" : "Blender",
- "conduit_uri" : "http://developer.blender.org/",
+ "conduit_uri" : "https://developer.blender.org/",
"git.default-relative-commit" : "origin/master",
"arc.land.update.default" : "rebase"
}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0d53015e994..106c80762af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1506,18 +1506,13 @@ elseif(WIN32)
if(WITH_OPENAL)
set(OPENAL ${LIBDIR}/openal)
set(OPENALDIR ${LIBDIR}/openal)
- find_package(OPENAL)
-
- if(NOT OPENAL_FOUND)
- message(WARNING "Setting static openAL paths")
- set(OPENAL_INCLUDE_DIR ${OPENAL}/include)
- if(MSVC11 OR MSVC12)
- set(OPENAL_LIBRARY openal32)
- else()
- set(OPENAL_LIBRARY wrap_oal)
- endif()
+ set(OPENAL_INCLUDE_DIR ${OPENAL}/include)
+ if(MSVC11 OR MSVC12)
+ set(OPENAL_LIBRARY openal32)
+ else()
+ set(OPENAL_LIBRARY wrap_oal)
+ endif()
set(OPENAL_LIBPATH ${OPENAL}/lib)
- endif()
endif()
if(WITH_CODEC_SNDFILE)
diff --git a/doc/python_api/rst/info_tips_and_tricks.rst b/doc/python_api/rst/info_tips_and_tricks.rst
index 75e8ef61f6f..793259401b8 100644
--- a/doc/python_api/rst/info_tips_and_tricks.rst
+++ b/doc/python_api/rst/info_tips_and_tricks.rst
@@ -214,7 +214,7 @@ The next example is an equivalent single line version of the script above which
.. code-block:: python
- __import__('code').interact(local={k: v for ns in (globals(), locals()) for k, v in ns.items()})
+ __import__('code').interact(local=dict(globals(), **locals()))
``code.interact`` can be added at any line in the script and will pause the script an launch an interactive interpreter in the terminal, when you're done you can quit the interpreter and the script will continue execution.
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
index 093c6f9b200..d739a2a08d7 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
@@ -770,7 +770,7 @@ void btCollisionWorld::objectQuerySingleInternal(const btConvexShape* castShape,
hitPointLocal,
hitFraction);
- bool normalInWorldSpace = false;
+ bool normalInWorldSpace = true;
return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace);
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
index 991841ee20b..286e6c31f2f 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
@@ -229,6 +229,7 @@ void btCompoundCollisionAlgorithm::processCollision (const btCollisionObjectWrap
removeChildAlgorithms();
preallocateChildAlgorithms(body0Wrap,body1Wrap);
+ m_compoundShapeRevision = compoundShape->getUpdateRevision();
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
index 53675145637..7d792c18d34 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
@@ -36,6 +36,7 @@ extern btShapePairCallback gCompoundChildShapePairCallback;
/// btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision shapes
class btCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm
{
+protected:
btAlignedObjectArray<btCollisionAlgorithm*> m_childCollisionAlgorithms;
bool m_isSwapped;
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp
index a52dd34fe91..95780fb2d27 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp
@@ -27,10 +27,8 @@ subject to the following restrictions:
btShapePairCallback gCompoundCompoundChildShapePairCallback = 0;
btCompoundCompoundCollisionAlgorithm::btCompoundCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped)
-:btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap),
-m_sharedManifold(ci.m_manifold)
+:btCompoundCollisionAlgorithm(ci,body0Wrap,body1Wrap,isSwapped)
{
- m_ownsManifold = false;
void* ptr = btAlignedAlloc(sizeof(btHashedSimplePairCache),16);
m_childCollisionAlgorithmCache= new(ptr) btHashedSimplePairCache();
@@ -292,12 +290,21 @@ void btCompoundCompoundCollisionAlgorithm::processCollision (const btCollisionOb
const btCompoundShape* compoundShape0 = static_cast<const btCompoundShape*>(col0ObjWrap->getCollisionShape());
const btCompoundShape* compoundShape1 = static_cast<const btCompoundShape*>(col1ObjWrap->getCollisionShape());
+ const btDbvt* tree0 = compoundShape0->getDynamicAabbTree();
+ const btDbvt* tree1 = compoundShape1->getDynamicAabbTree();
+ if (!tree0 || !tree1)
+ {
+ return btCompoundCollisionAlgorithm::processCollision(body0Wrap,body1Wrap,dispatchInfo,resultOut);
+ }
///btCompoundShape might have changed:
////make sure the internal child collision algorithm caches are still valid
if ((compoundShape0->getUpdateRevision() != m_compoundShapeRevision0) || (compoundShape1->getUpdateRevision() != m_compoundShapeRevision1))
{
///clear all
removeChildAlgorithms();
+ m_compoundShapeRevision0 = compoundShape0->getUpdateRevision();
+ m_compoundShapeRevision1 = compoundShape1->getUpdateRevision();
+
}
@@ -329,8 +336,7 @@ void btCompoundCompoundCollisionAlgorithm::processCollision (const btCollisionOb
}
- const btDbvt* tree0 = compoundShape0->getDynamicAabbTree();
- const btDbvt* tree1 = compoundShape1->getDynamicAabbTree();
+
btCompoundCompoundLeafCallback callback(col0ObjWrap,col1ObjWrap,this->m_dispatcher,dispatchInfo,resultOut,this->m_childCollisionAlgorithmCache,m_sharedManifold);
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h
index 7e2d7ad7085..06a762f209d 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h
@@ -17,6 +17,8 @@ subject to the following restrictions:
#ifndef BT_COMPOUND_COMPOUND_COLLISION_ALGORITHM_H
#define BT_COMPOUND_COMPOUND_COLLISION_ALGORITHM_H
+#include "btCompoundCollisionAlgorithm.h"
+
#include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h"
#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
@@ -35,15 +37,12 @@ typedef bool (*btShapePairCallback)(const btCollisionShape* pShape0, const btCol
extern btShapePairCallback gCompoundCompoundChildShapePairCallback;
/// btCompoundCompoundCollisionAlgorithm supports collision between two btCompoundCollisionShape shapes
-class btCompoundCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm
+class btCompoundCompoundCollisionAlgorithm : public btCompoundCollisionAlgorithm
{
class btHashedSimplePairCache* m_childCollisionAlgorithmCache;
btSimplePairArray m_removePairs;
- class btPersistentManifold* m_sharedManifold;
- bool m_ownsManifold;
-
int m_compoundShapeRevision0;//to keep track of changes, so that childAlgorithm array can be updated
int m_compoundShapeRevision1;
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h
index 1ba1cd1e839..890afe6da42 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h
@@ -33,7 +33,8 @@ class btDispatcher;
enum btConstraintSolverType
{
BT_SEQUENTIAL_IMPULSE_SOLVER=1,
- BT_MLCP_SOLVER=2
+ BT_MLCP_SOLVER=2,
+ BT_NNCG_SOLVER=4
};
class btConstraintSolver
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp
index f93a3280f35..3428e0b069d 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp
@@ -23,9 +23,8 @@ subject to the following restrictions:
btFixedConstraint::btFixedConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& frameInA,const btTransform& frameInB)
:btTypedConstraint(FIXED_CONSTRAINT_TYPE,rbA,rbB)
{
- m_pivotInA = frameInA.getOrigin();
- m_pivotInB = frameInB.getOrigin();
- m_relTargetAB = frameInA.getRotation()*frameInB.getRotation().inverse();
+ m_frameInA = frameInA;
+ m_frameInB = frameInB;
}
@@ -37,14 +36,16 @@ btFixedConstraint::~btFixedConstraint ()
void btFixedConstraint::getInfo1 (btConstraintInfo1* info)
{
info->m_numConstraintRows = 6;
- info->nub = 6;
+ info->nub = 0;
}
void btFixedConstraint::getInfo2 (btConstraintInfo2* info)
{
//fix the 3 linear degrees of freedom
-
+ const btTransform& transA = m_rbA.getCenterOfMassTransform();
+ const btTransform& transB = m_rbB.getCenterOfMassTransform();
+
const btVector3& worldPosA = m_rbA.getCenterOfMassTransform().getOrigin();
const btMatrix3x3& worldOrnA = m_rbA.getCenterOfMassTransform().getBasis();
const btVector3& worldPosB= m_rbB.getCenterOfMassTransform().getOrigin();
@@ -55,15 +56,15 @@ void btFixedConstraint::getInfo2 (btConstraintInfo2* info)
info->m_J1linearAxis[info->rowskip+1] = 1;
info->m_J1linearAxis[2*info->rowskip+2] = 1;
- btVector3 a1 = worldOrnA*m_pivotInA;
- {
+ btVector3 a1 = worldOrnA * m_frameInA.getOrigin();
+ {
btVector3* angular0 = (btVector3*)(info->m_J1angularAxis);
btVector3* angular1 = (btVector3*)(info->m_J1angularAxis+info->rowskip);
btVector3* angular2 = (btVector3*)(info->m_J1angularAxis+2*info->rowskip);
btVector3 a1neg = -a1;
a1neg.getSkewSymmetricMatrix(angular0,angular1,angular2);
}
-
+
if (info->m_J2linearAxis)
{
info->m_J2linearAxis[0] = -1;
@@ -71,10 +72,8 @@ void btFixedConstraint::getInfo2 (btConstraintInfo2* info)
info->m_J2linearAxis[2*info->rowskip+2] = -1;
}
- btVector3 a2 = worldOrnB*m_pivotInB;
-
- {
- // btVector3 a2n = -a2;
+ btVector3 a2 = worldOrnB*m_frameInB.getOrigin();
+ {
btVector3* angular0 = (btVector3*)(info->m_J2angularAxis);
btVector3* angular1 = (btVector3*)(info->m_J2angularAxis+info->rowskip);
btVector3* angular2 = (btVector3*)(info->m_J2angularAxis+2*info->rowskip);
@@ -88,42 +87,100 @@ void btFixedConstraint::getInfo2 (btConstraintInfo2* info)
int j;
for (j=0; j<3; j++)
{
-
-
-
info->m_constraintError[j*info->rowskip] = linearError[j];
//printf("info->m_constraintError[%d]=%f\n",j,info->m_constraintError[j]);
}
- //fix the 3 angular degrees of freedom
-
- int start_row = 3;
- int s = info->rowskip;
- int start_index = start_row * s;
-
- // 3 rows to make body rotations equal
- info->m_J1angularAxis[start_index] = 1;
- info->m_J1angularAxis[start_index + s + 1] = 1;
- info->m_J1angularAxis[start_index + s*2+2] = 1;
- if ( info->m_J2angularAxis)
- {
- info->m_J2angularAxis[start_index] = -1;
- info->m_J2angularAxis[start_index + s+1] = -1;
- info->m_J2angularAxis[start_index + s*2+2] = -1;
- }
-
- // set right hand side for the angular dofs
-
- btVector3 diff;
- btScalar angle;
- btMatrix3x3 mrelCur = worldOrnA *worldOrnB.inverse();
- btQuaternion qrelCur;
- mrelCur.getRotation(qrelCur);
- btTransformUtil::calculateDiffAxisAngleQuaternion(m_relTargetAB,qrelCur,diff,angle);
- diff*=-angle;
- for (j=0; j<3; j++)
- {
- info->m_constraintError[(3+j)*info->rowskip] = k * diff[j];
- }
-
+ btVector3 ivA = transA.getBasis() * m_frameInA.getBasis().getColumn(0);
+ btVector3 jvA = transA.getBasis() * m_frameInA.getBasis().getColumn(1);
+ btVector3 kvA = transA.getBasis() * m_frameInA.getBasis().getColumn(2);
+ btVector3 ivB = transB.getBasis() * m_frameInB.getBasis().getColumn(0);
+ btVector3 target;
+ btScalar x = ivB.dot(ivA);
+ btScalar y = ivB.dot(jvA);
+ btScalar z = ivB.dot(kvA);
+ btVector3 swingAxis(0,0,0);
+ {
+ if((!btFuzzyZero(y)) || (!(btFuzzyZero(z))))
+ {
+ swingAxis = -ivB.cross(ivA);
+ }
+ }
+ btVector3 vTwist(1,0,0);
+
+ // compute rotation of A wrt B (in constraint space)
+ btQuaternion qA = transA.getRotation() * m_frameInA.getRotation();
+ btQuaternion qB = transB.getRotation() * m_frameInB.getRotation();
+ btQuaternion qAB = qB.inverse() * qA;
+ // split rotation into cone and twist
+ // (all this is done from B's perspective. Maybe I should be averaging axes...)
+ btVector3 vConeNoTwist = quatRotate(qAB, vTwist); vConeNoTwist.normalize();
+ btQuaternion qABCone = shortestArcQuat(vTwist, vConeNoTwist); qABCone.normalize();
+ btQuaternion qABTwist = qABCone.inverse() * qAB; qABTwist.normalize();
+
+ int row = 3;
+ int srow = row * info->rowskip;
+ btVector3 ax1;
+ // angular limits
+ {
+ btScalar *J1 = info->m_J1angularAxis;
+ btScalar *J2 = info->m_J2angularAxis;
+ btTransform trA = transA*m_frameInA;
+ btVector3 twistAxis = trA.getBasis().getColumn(0);
+
+ btVector3 p = trA.getBasis().getColumn(1);
+ btVector3 q = trA.getBasis().getColumn(2);
+ int srow1 = srow + info->rowskip;
+ J1[srow+0] = p[0];
+ J1[srow+1] = p[1];
+ J1[srow+2] = p[2];
+ J1[srow1+0] = q[0];
+ J1[srow1+1] = q[1];
+ J1[srow1+2] = q[2];
+ J2[srow+0] = -p[0];
+ J2[srow+1] = -p[1];
+ J2[srow+2] = -p[2];
+ J2[srow1+0] = -q[0];
+ J2[srow1+1] = -q[1];
+ J2[srow1+2] = -q[2];
+ btScalar fact = info->fps;
+ info->m_constraintError[srow] = fact * swingAxis.dot(p);
+ info->m_constraintError[srow1] = fact * swingAxis.dot(q);
+ info->m_lowerLimit[srow] = -SIMD_INFINITY;
+ info->m_upperLimit[srow] = SIMD_INFINITY;
+ info->m_lowerLimit[srow1] = -SIMD_INFINITY;
+ info->m_upperLimit[srow1] = SIMD_INFINITY;
+ srow = srow1 + info->rowskip;
+
+ {
+ btQuaternion qMinTwist = qABTwist;
+ btScalar twistAngle = qABTwist.getAngle();
+
+ if (twistAngle > SIMD_PI) // long way around. flip quat and recalculate.
+ {
+ qMinTwist = -(qABTwist);
+ twistAngle = qMinTwist.getAngle();
+ }
+
+ if (twistAngle > SIMD_EPSILON)
+ {
+ twistAxis = btVector3(qMinTwist.x(), qMinTwist.y(), qMinTwist.z());
+ twistAxis.normalize();
+ twistAxis = quatRotate(qB, -twistAxis);
+ }
+ ax1 = twistAxis;
+ btScalar *J1 = info->m_J1angularAxis;
+ btScalar *J2 = info->m_J2angularAxis;
+ J1[srow+0] = ax1[0];
+ J1[srow+1] = ax1[1];
+ J1[srow+2] = ax1[2];
+ J2[srow+0] = -ax1[0];
+ J2[srow+1] = -ax1[1];
+ J2[srow+2] = -ax1[2];
+ btScalar k = info->fps;
+ info->m_constraintError[srow] = k * twistAngle;
+ info->m_lowerLimit[srow] = -SIMD_INFINITY;
+ info->m_upperLimit[srow] = SIMD_INFINITY;
+ }
+ }
} \ No newline at end of file
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h
index 697e319e2ce..e1c9430fd3c 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h
@@ -20,10 +20,9 @@ subject to the following restrictions:
ATTRIBUTE_ALIGNED16(class) btFixedConstraint : public btTypedConstraint
{
- btVector3 m_pivotInA;
- btVector3 m_pivotInB;
- btQuaternion m_relTargetAB;
+ btTransform m_frameInA;
+ btTransform m_frameInB;
public:
btFixedConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& frameInA,const btTransform& frameInB);
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
index be93e35434c..f855581c712 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
@@ -58,13 +58,13 @@ static inline __m128 btSimdDot3( __m128 vec0, __m128 vec1 )
#endif//USE_SIMD
// Project Gauss Seidel or the equivalent Sequential Impulse
-void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGenericSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c)
+btSimdScalar btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGenericSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c)
{
#ifdef USE_SIMD
__m128 cpAppliedImp = _mm_set1_ps(c.m_appliedImpulse);
__m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit);
__m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit);
- __m128 deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhs), _mm_mul_ps(_mm_set1_ps(c.m_appliedImpulse),_mm_set1_ps(c.m_cfm)));
+ btSimdScalar deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhs), _mm_mul_ps(_mm_set1_ps(c.m_appliedImpulse),_mm_set1_ps(c.m_cfm)));
__m128 deltaVel1Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal1.mVec128,body1.internalGetDeltaLinearVelocity().mVec128), btSimdDot3(c.m_relpos1CrossNormal.mVec128,body1.internalGetDeltaAngularVelocity().mVec128));
__m128 deltaVel2Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal2.mVec128,body2.internalGetDeltaLinearVelocity().mVec128), btSimdDot3(c.m_relpos2CrossNormal.mVec128,body2.internalGetDeltaAngularVelocity().mVec128));
deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel1Dotn,_mm_set1_ps(c.m_jacDiagABInv)));
@@ -86,13 +86,15 @@ void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGenericSIMD(
body1.internalGetDeltaAngularVelocity().mVec128 = _mm_add_ps(body1.internalGetDeltaAngularVelocity().mVec128 ,_mm_mul_ps(c.m_angularComponentA.mVec128,impulseMagnitude));
body2.internalGetDeltaLinearVelocity().mVec128 = _mm_add_ps(body2.internalGetDeltaLinearVelocity().mVec128,_mm_mul_ps(linearComponentB,impulseMagnitude));
body2.internalGetDeltaAngularVelocity().mVec128 = _mm_add_ps(body2.internalGetDeltaAngularVelocity().mVec128 ,_mm_mul_ps(c.m_angularComponentB.mVec128,impulseMagnitude));
+
+ return deltaImpulse;
#else
- resolveSingleConstraintRowGeneric(body1,body2,c);
+ return resolveSingleConstraintRowGeneric(body1,body2,c);
#endif
}
// Project Gauss Seidel or the equivalent Sequential Impulse
- void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGeneric(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c)
+btSimdScalar btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGeneric(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c)
{
btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm;
const btScalar deltaVel1Dotn = c.m_contactNormal1.dot(body1.internalGetDeltaLinearVelocity()) + c.m_relpos1CrossNormal.dot(body1.internalGetDeltaAngularVelocity());
@@ -120,15 +122,17 @@ void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGenericSIMD(
body1.internalApplyImpulse(c.m_contactNormal1*body1.internalGetInvMass(),c.m_angularComponentA,deltaImpulse);
body2.internalApplyImpulse(c.m_contactNormal2*body2.internalGetInvMass(),c.m_angularComponentB,deltaImpulse);
+
+ return deltaImpulse;
}
- void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c)
+btSimdScalar btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c)
{
#ifdef USE_SIMD
__m128 cpAppliedImp = _mm_set1_ps(c.m_appliedImpulse);
__m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit);
__m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit);
- __m128 deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhs), _mm_mul_ps(_mm_set1_ps(c.m_appliedImpulse),_mm_set1_ps(c.m_cfm)));
+ btSimdScalar deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhs), _mm_mul_ps(_mm_set1_ps(c.m_appliedImpulse),_mm_set1_ps(c.m_cfm)));
__m128 deltaVel1Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal1.mVec128,body1.internalGetDeltaLinearVelocity().mVec128), btSimdDot3(c.m_relpos1CrossNormal.mVec128,body1.internalGetDeltaAngularVelocity().mVec128));
__m128 deltaVel2Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal2.mVec128,body2.internalGetDeltaLinearVelocity().mVec128), btSimdDot3(c.m_relpos2CrossNormal.mVec128,body2.internalGetDeltaAngularVelocity().mVec128));
deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel1Dotn,_mm_set1_ps(c.m_jacDiagABInv)));
@@ -147,13 +151,14 @@ void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGenericSIMD(
body1.internalGetDeltaAngularVelocity().mVec128 = _mm_add_ps(body1.internalGetDeltaAngularVelocity().mVec128 ,_mm_mul_ps(c.m_angularComponentA.mVec128,impulseMagnitude));
body2.internalGetDeltaLinearVelocity().mVec128 = _mm_add_ps(body2.internalGetDeltaLinearVelocity().mVec128,_mm_mul_ps(linearComponentB,impulseMagnitude));
body2.internalGetDeltaAngularVelocity().mVec128 = _mm_add_ps(body2.internalGetDeltaAngularVelocity().mVec128 ,_mm_mul_ps(c.m_angularComponentB.mVec128,impulseMagnitude));
+ return deltaImpulse;
#else
- resolveSingleConstraintRowLowerLimit(body1,body2,c);
+ return resolveSingleConstraintRowLowerLimit(body1,body2,c);
#endif
}
-// Projected Gauss Seidel or the equivalent Sequential Impulse
- void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimit(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c)
+
+btSimdScalar btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimit(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c)
{
btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm;
const btScalar deltaVel1Dotn = c.m_contactNormal1.dot(body1.internalGetDeltaLinearVelocity()) + c.m_relpos1CrossNormal.dot(body1.internalGetDeltaAngularVelocity());
@@ -173,6 +178,8 @@ void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGenericSIMD(
}
body1.internalApplyImpulse(c.m_contactNormal1*body1.internalGetInvMass(),c.m_angularComponentA,deltaImpulse);
body2.internalApplyImpulse(c.m_contactNormal2*body2.internalGetInvMass(),c.m_angularComponentB,deltaImpulse);
+
+ return deltaImpulse;
}
@@ -430,6 +437,7 @@ void btSequentialImpulseConstraintSolver::setupFrictionConstraint(btSolverConstr
btSimdScalar velocityError = desiredVelocity - rel_vel;
btSimdScalar velocityImpulse = velocityError * btSimdScalar(solverConstraint.m_jacDiagABInv);
solverConstraint.m_rhs = velocityImpulse;
+ solverConstraint.m_rhsPenetration = 0.f;
solverConstraint.m_cfm = cfmSlip;
solverConstraint.m_lowerLimit = -solverConstraint.m_friction;
solverConstraint.m_upperLimit = solverConstraint.m_friction;
@@ -812,7 +820,7 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
///avoid collision response between two static objects
- if (!solverBodyA || (solverBodyA->m_invMass.isZero() && (!solverBodyB || solverBodyB->m_invMass.isZero())))
+ if (!solverBodyA || (solverBodyA->m_invMass.fuzzyZero() && (!solverBodyB || solverBodyB->m_invMass.fuzzyZero())))
return;
int rollingFriction=1;
@@ -1452,8 +1460,7 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
for (j=0;j<numPoolConstraints;j++)
{
const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[m_orderTmpConstraintPool[j]];
- //resolveSingleConstraintRowLowerLimitSIMD(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
- resolveSingleConstraintRowLowerLimit(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
+ resolveSingleConstraintRowLowerLimitSIMD(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
}
@@ -1472,8 +1479,7 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
solveManifold.m_lowerLimit = -(solveManifold.m_friction*totalImpulse);
solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse;
- //resolveSingleConstraintRowGenericSIMD(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
- resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
+ resolveSingleConstraintRowGenericSIMD(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
}
}
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h
index 180d2a385d3..47dbbe3393d 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h
@@ -88,13 +88,10 @@ protected:
int getOrInitSolverBody(btCollisionObject& body,btScalar timeStep);
void initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject, btScalar timeStep);
- void resolveSingleConstraintRowGeneric(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
-
- void resolveSingleConstraintRowGenericSIMD(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
-
- void resolveSingleConstraintRowLowerLimit(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
-
- void resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
+ btSimdScalar resolveSingleConstraintRowGeneric(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
+ btSimdScalar resolveSingleConstraintRowGenericSIMD(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
+ btSimdScalar resolveSingleConstraintRowLowerLimit(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
+ btSimdScalar resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
protected:
diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp
index 8888d3961f5..0635b958bed 100644
--- a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp
+++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp
@@ -19,9 +19,11 @@ subject to the following restrictions:
#include "LinearMath/btQuickprof.h"
#include "btSolveProjectedGaussSeidel.h"
+
btMLCPSolver::btMLCPSolver( btMLCPSolverInterface* solver)
:m_solver(solver),
-m_fallback(0)
+m_fallback(0),
+m_cfm(0.000001)//0.0000001
{
}
@@ -160,13 +162,17 @@ void btMLCPSolver::createMLCPFast(const btContactSolverInfo& infoGlobal)
BT_PROFILE("init b (rhs)");
m_b.resize(numConstraintRows);
m_bSplit.resize(numConstraintRows);
- //m_b.setZero();
+ m_b.setZero();
+ m_bSplit.setZero();
for (int i=0;i<numConstraintRows ;i++)
{
- if (m_allConstraintArray[i].m_jacDiagABInv)
+ btScalar jacDiag = m_allConstraintArray[i].m_jacDiagABInv;
+ if (!btFuzzyZero(jacDiag))
{
- m_b[i]=m_allConstraintArray[i].m_rhs/m_allConstraintArray[i].m_jacDiagABInv;
- m_bSplit[i] = m_allConstraintArray[i].m_rhsPenetration/m_allConstraintArray[i].m_jacDiagABInv;
+ btScalar rhs = m_allConstraintArray[i].m_rhs;
+ btScalar rhsPenetration = m_allConstraintArray[i].m_rhsPenetration;
+ m_b[i]=rhs/jacDiag;
+ m_bSplit[i] = rhsPenetration/jacDiag;
}
}
@@ -425,14 +431,12 @@ void btMLCPSolver::createMLCPFast(const btContactSolverInfo& infoGlobal)
}
}
- ///todo: use proper cfm values from the constraints (getInfo2)
if (1)
{
// add cfm to the diagonal of m_A
for ( int i=0; i<m_A.rows(); ++i)
{
- float cfm = 0.00001f;
- m_A.setElem(i,i,m_A(i,i)+ cfm / infoGlobal.m_timeStep);
+ m_A.setElem(i,i,m_A(i,i)+ m_cfm / infoGlobal.m_timeStep);
}
}
@@ -473,6 +477,9 @@ void btMLCPSolver::createMLCP(const btContactSolverInfo& infoGlobal)
if (infoGlobal.m_splitImpulse)
m_bSplit.resize(numConstraintRows);
+ m_bSplit.setZero();
+ m_b.setZero();
+
for (int i=0;i<numConstraintRows ;i++)
{
if (m_allConstraintArray[i].m_jacDiagABInv)
@@ -554,12 +561,10 @@ void btMLCPSolver::createMLCP(const btContactSolverInfo& infoGlobal)
if (1)
{
- ///todo: use proper cfm values from the constraints (getInfo2)
// add cfm to the diagonal of m_A
for ( int i=0; i<m_A.rows(); ++i)
{
- float cfm = 0.0001f;
- m_A.setElem(i,i,m_A(i,i)+ cfm / infoGlobal.m_timeStep);
+ m_A.setElem(i,i,m_A(i,i)+ m_cfm / infoGlobal.m_timeStep);
}
}
@@ -618,6 +623,7 @@ btScalar btMLCPSolver::solveGroupCacheFriendlyIterations(btCollisionObject** bod
}
else
{
+ // printf("m_fallback = %d\n",m_fallback);
m_fallback++;
btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer);
}
diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h
index a5dae2d28f6..31e8eb88ba5 100644
--- a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h
+++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h
@@ -42,6 +42,7 @@ protected:
btConstraintArray m_allConstraintArray;
btMLCPSolverInterface* m_solver;
int m_fallback;
+ btScalar m_cfm;
virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
@@ -70,6 +71,15 @@ public:
m_fallback = num;
}
+ btScalar getCfm() const
+ {
+ return m_cfm;
+ }
+ void setCfm(btScalar cfm)
+ {
+ m_cfm = cfm;
+ }
+
virtual btConstraintSolverType getSolverType() const
{
return BT_MLCP_SOLVER;
diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h
index 44fbfeadddc..d2ad54d21a8 100644
--- a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h
+++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h
@@ -20,11 +20,17 @@ subject to the following restrictions:
#include "btMLCPSolverInterface.h"
+///This solver is mainly for debug/learning purposes: it is functionally equivalent to the btSequentialImpulseConstraintSolver solver, but much slower (it builds the full LCP matrix)
class btSolveProjectedGaussSeidel : public btMLCPSolverInterface
{
public:
virtual bool solveMLCP(const btMatrixXu & A, const btVectorXu & b, btVectorXu& x, const btVectorXu & lo,const btVectorXu & hi,const btAlignedObjectArray<int>& limitDependency, int numIterations, bool useSparsity = true)
{
+ if (!A.rows())
+ return true;
+ //the A matrix is sparse, so compute the non-zero elements
+ A.rowComputeNonZeroElements();
+
//A is a m-n matrix, m rows, n columns
btAssert(A.rows() == b.rows());
diff --git a/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp b/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp
index 9429d56e05a..2bfd62f2a2f 100644
--- a/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp
+++ b/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp
@@ -3027,7 +3027,8 @@ void btSoftBody::PSolve_RContacts(btSoftBody* psb, btScalar kst, btScalar ti)
{
const RContact& c = psb->m_rcontacts[i];
const sCti& cti = c.m_cti;
- if (cti.m_colObj->hasContactResponse()) {
+ if (cti.m_colObj->hasContactResponse())
+ {
btRigidBody* tmpRigid = (btRigidBody*)btRigidBody::upcast(cti.m_colObj);
const btVector3 va = tmpRigid ? tmpRigid->getVelocityInLocalPoint(c.m_c1)*dt : btVector3(0,0,0);
const btVector3 vb = c.m_node->m_x-c.m_node->m_q;
diff --git a/extern/bullet2/src/LinearMath/btMatrixX.h b/extern/bullet2/src/LinearMath/btMatrixX.h
index 1c29632c536..865d77967a9 100644
--- a/extern/bullet2/src/LinearMath/btMatrixX.h
+++ b/extern/bullet2/src/LinearMath/btMatrixX.h
@@ -20,6 +20,12 @@ subject to the following restrictions:
#include "LinearMath/btQuickprof.h"
#include "LinearMath/btAlignedObjectArray.h"
+//#define BT_DEBUG_OSTREAM
+#ifdef BT_DEBUG_OSTREAM
+#include <iostream>
+#include <iomanip> // std::setw
+#endif //BT_DEBUG_OSTREAM
+
class btIntSortPredicate
{
public:
@@ -30,6 +36,121 @@ class btIntSortPredicate
};
+template <typename T>
+struct btVectorX
+{
+ btAlignedObjectArray<T> m_storage;
+
+ btVectorX()
+ {
+ }
+ btVectorX(int numRows)
+ {
+ m_storage.resize(numRows);
+ }
+
+ void resize(int rows)
+ {
+ m_storage.resize(rows);
+ }
+ int cols() const
+ {
+ return 1;
+ }
+ int rows() const
+ {
+ return m_storage.size();
+ }
+ int size() const
+ {
+ return rows();
+ }
+
+ T nrm2() const
+ {
+ T norm = T(0);
+
+ int nn = rows();
+
+ {
+ if (nn == 1)
+ {
+ norm = btFabs((*this)[0]);
+ }
+ else
+ {
+ T scale = 0.0;
+ T ssq = 1.0;
+
+ /* The following loop is equivalent to this call to the LAPACK
+ auxiliary routine: CALL SLASSQ( N, X, INCX, SCALE, SSQ ) */
+
+ for (int ix=0;ix<nn;ix++)
+ {
+ if ((*this)[ix] != 0.0)
+ {
+ T absxi = btFabs((*this)[ix]);
+ if (scale < absxi)
+ {
+ T temp;
+ temp = scale / absxi;
+ ssq = ssq * (temp * temp) + 1.0;
+ scale = absxi;
+ }
+ else
+ {
+ T temp;
+ temp = absxi / scale;
+ ssq += temp * temp;
+ }
+ }
+ }
+ norm = scale * sqrt(ssq);
+ }
+ }
+ return norm;
+
+ }
+ void setZero()
+ {
+ if (m_storage.size())
+ {
+ // for (int i=0;i<m_storage.size();i++)
+ // m_storage[i]=0;
+ //memset(&m_storage[0],0,sizeof(T)*m_storage.size());
+ btSetZero(&m_storage[0],m_storage.size());
+ }
+ }
+ const T& operator[] (int index) const
+ {
+ return m_storage[index];
+ }
+
+ T& operator[] (int index)
+ {
+ return m_storage[index];
+ }
+
+ T* getBufferPointerWritable()
+ {
+ return m_storage.size() ? &m_storage[0] : 0;
+ }
+
+ const T* getBufferPointer() const
+ {
+ return m_storage.size() ? &m_storage[0] : 0;
+ }
+
+};
+/*
+ template <typename T>
+ void setElem(btMatrixX<T>& mat, int row, int col, T val)
+ {
+ mat.setElem(row,col,val);
+ }
+ */
+
+
template <typename T>
struct btMatrixX
{
@@ -40,8 +161,7 @@ struct btMatrixX
int m_setElemOperations;
btAlignedObjectArray<T> m_storage;
- btAlignedObjectArray< btAlignedObjectArray<int> > m_rowNonZeroElements1;
- btAlignedObjectArray< btAlignedObjectArray<int> > m_colNonZeroElements;
+ mutable btAlignedObjectArray< btAlignedObjectArray<int> > m_rowNonZeroElements1;
T* getBufferPointerWritable()
{
@@ -78,7 +198,6 @@ struct btMatrixX
BT_PROFILE("m_storage.resize");
m_storage.resize(rows*cols);
}
- clearSparseInfo();
}
int cols() const
{
@@ -109,49 +228,44 @@ struct btMatrixX
}
}
+
+ void setElem(int row,int col, T val)
+ {
+ m_setElemOperations++;
+ m_storage[row*m_cols+col] = val;
+ }
+
+ void mulElem(int row,int col, T val)
+ {
+ m_setElemOperations++;
+ //mul doesn't change sparsity info
+
+ m_storage[row*m_cols+col] *= val;
+ }
+
+
+
+
void copyLowerToUpperTriangle()
{
int count=0;
- for (int row=0;row<m_rowNonZeroElements1.size();row++)
+ for (int row=0;row<rows();row++)
{
- for (int j=0;j<m_rowNonZeroElements1[row].size();j++)
+ for (int col=0;col<row;col++)
{
- int col = m_rowNonZeroElements1[row][j];
setElem(col,row, (*this)(row,col));
count++;
-
+
}
}
//printf("copyLowerToUpperTriangle copied %d elements out of %dx%d=%d\n", count,rows(),cols(),cols()*rows());
}
- void setElem(int row,int col, T val)
- {
- m_setElemOperations++;
- if (val)
- {
- if (m_storage[col+row*m_cols]==0.f)
- {
- m_rowNonZeroElements1[row].push_back(col);
- m_colNonZeroElements[col].push_back(row);
- }
- m_storage[row*m_cols+col] = val;
- }
- }
+
const T& operator() (int row,int col) const
{
return m_storage[col+row*m_cols];
}
- void clearSparseInfo()
- {
- BT_PROFILE("clearSparseInfo=0");
- m_rowNonZeroElements1.resize(m_rows);
- m_colNonZeroElements.resize(m_cols);
- for (int i=0;i<m_rows;i++)
- m_rowNonZeroElements1[i].resize(0);
- for (int j=0;j<m_cols;j++)
- m_colNonZeroElements[j].resize(0);
- }
void setZero()
{
@@ -162,12 +276,21 @@ struct btMatrixX
//for (int i=0;i<m_storage.size();i++)
// m_storage[i]=0;
}
+ }
+
+ void setIdentity()
+ {
+ btAssert(rows() == cols());
+
+ setZero();
+ for (int row=0;row<rows();row++)
{
- BT_PROFILE("clearSparseInfo=0");
- clearSparseInfo();
+ setElem(row,row,1);
}
}
+
+
void printMatrix(const char* msg)
{
printf("%s ---------------------\n",msg);
@@ -182,28 +305,9 @@ struct btMatrixX
printf("\n---------------------\n");
}
- void printNumZeros(const char* msg)
- {
- printf("%s: ",msg);
- int numZeros = 0;
- for (int i=0;i<m_storage.size();i++)
- if (m_storage[i]==0)
- numZeros++;
- int total = m_cols*m_rows;
- int computedNonZero = total-numZeros;
- int nonZero = 0;
- for (int i=0;i<m_colNonZeroElements.size();i++)
- nonZero += m_colNonZeroElements[i].size();
- btAssert(computedNonZero==nonZero);
- if(computedNonZero!=nonZero)
- {
- printf("Error: computedNonZero=%d, but nonZero=%d\n",computedNonZero,nonZero);
- }
- //printf("%d numZeros out of %d (%f)\n",numZeros,m_cols*m_rows,numZeros/(m_cols*m_rows));
- printf("total %d, %d rows, %d cols, %d non-zeros (%f %)\n", total, rows(),cols(), nonZero,100.f*(T)nonZero/T(total));
- }
- /*
- void rowComputeNonZeroElements()
+
+
+ void rowComputeNonZeroElements() const
{
m_rowNonZeroElements1.resize(rows());
for (int i=0;i<rows();i++)
@@ -218,13 +322,11 @@ struct btMatrixX
}
}
}
- */
btMatrixX transpose() const
{
//transpose is optimized for sparse matrices
btMatrixX tr(m_cols,m_rows);
tr.setZero();
-#if 0
for (int i=0;i<m_cols;i++)
for (int j=0;j<m_rows;j++)
{
@@ -234,37 +336,13 @@ struct btMatrixX
tr.setElem(i,j,v);
}
}
-#else
- for (int i=0;i<m_colNonZeroElements.size();i++)
- for (int h=0;h<m_colNonZeroElements[i].size();h++)
- {
- int j = m_colNonZeroElements[i][h];
- T v = (*this)(j,i);
- tr.setElem(i,j,v);
- }
-#endif
return tr;
}
- void sortRowIndexArrays()
- {
- for (int i=0;i<m_rowNonZeroElements1[i].size();i++)
- {
- m_rowNonZeroElements1[i].quickSort(btIntSortPredicate());
- }
- }
-
- void sortColIndexArrays()
- {
- for (int i=0;i<m_colNonZeroElements[i].size();i++)
- {
- m_colNonZeroElements[i].quickSort(btIntSortPredicate());
- }
- }
btMatrixX operator*(const btMatrixX& other)
{
- //btMatrixX*btMatrixX implementation, optimized for sparse matrices
+ //btMatrixX*btMatrixX implementation, brute force
btAssert(cols() == other.rows());
btMatrixX res(rows(),other.cols());
@@ -272,76 +350,18 @@ struct btMatrixX
// BT_PROFILE("btMatrixX mul");
for (int j=0; j < res.cols(); ++j)
{
- //int numZero=other.m_colNonZeroElements[j].size();
- //if (numZero)
{
for (int i=0; i < res.rows(); ++i)
- //for (int g = 0;g<m_colNonZeroElements[j].size();g++)
{
T dotProd=0;
T dotProd2=0;
int waste=0,waste2=0;
- bool doubleWalk = false;
- if (doubleWalk)
- {
- int numRows = m_rowNonZeroElements1[i].size();
- int numOtherCols = other.m_colNonZeroElements[j].size();
- for (int ii=0;ii<numRows;ii++)
- {
- int vThis=m_rowNonZeroElements1[i][ii];
- }
-
- for (int ii=0;ii<numOtherCols;ii++)
- {
- int vOther = other.m_colNonZeroElements[j][ii];
- }
-
-
- int indexRow = 0;
- int indexOtherCol = 0;
- while (indexRow < numRows && indexOtherCol < numOtherCols)
- {
- int vThis=m_rowNonZeroElements1[i][indexRow];
- int vOther = other.m_colNonZeroElements[j][indexOtherCol];
- if (vOther==vThis)
- {
- dotProd += (*this)(i,vThis) * other(vThis,j);
- }
- if (vThis<vOther)
- {
- indexRow++;
- } else
- {
- indexOtherCol++;
- }
- }
-
- } else
{
bool useOtherCol = true;
- if (other.m_colNonZeroElements[j].size() <m_rowNonZeroElements1[i].size())
- {
- useOtherCol=true;
- }
- if (!useOtherCol )
{
- for (int q=0;q<other.m_colNonZeroElements[j].size();q++)
+ for (int v=0;v<rows();v++)
{
- int v = other.m_colNonZeroElements[j][q];
- T w = (*this)(i,v);
- if (w!=0.f)
- {
- dotProd+=w*other(v,j);
- }
-
- }
- }
- else
- {
- for (int q=0;q<m_rowNonZeroElements1[i].size();q++)
- {
- int v=m_rowNonZeroElements1[i][q];
T w = (*this)(i,v);
if (other(v,j)!=0.f)
{
@@ -404,73 +424,61 @@ struct btMatrixX
bb += 8;
}
}
-
-};
-
-template <typename T>
-struct btVectorX
-{
- btAlignedObjectArray<T> m_storage;
-
- btVectorX()
- {
- }
- btVectorX(int numRows)
- {
- m_storage.resize(numRows);
- }
-
- void resize(int rows)
- {
- m_storage.resize(rows);
- }
- int cols() const
- {
- return 1;
- }
- int rows() const
- {
- return m_storage.size();
- }
- int size() const
- {
- return rows();
- }
- void setZero()
- {
- // for (int i=0;i<m_storage.size();i++)
- // m_storage[i]=0;
- //memset(&m_storage[0],0,sizeof(T)*m_storage.size());
- btSetZero(&m_storage[0],m_storage.size());
- }
- const T& operator[] (int index) const
+
+ void setSubMatrix(int rowstart,int colstart,int rowend,int colend,const T value)
{
- return m_storage[index];
+ int numRows = rowend+1-rowstart;
+ int numCols = colend+1-colstart;
+
+ for (int row=0;row<numRows;row++)
+ {
+ for (int col=0;col<numCols;col++)
+ {
+ setElem(rowstart+row,colstart+col,value);
+ }
+ }
}
-
- T& operator[] (int index)
+
+ void setSubMatrix(int rowstart,int colstart,int rowend,int colend,const btMatrixX& block)
{
- return m_storage[index];
+ btAssert(rowend+1-rowstart == block.rows());
+ btAssert(colend+1-colstart == block.cols());
+ for (int row=0;row<block.rows();row++)
+ {
+ for (int col=0;col<block.cols();col++)
+ {
+ setElem(rowstart+row,colstart+col,block(row,col));
+ }
+ }
}
-
- T* getBufferPointerWritable()
+ void setSubMatrix(int rowstart,int colstart,int rowend,int colend,const btVectorX<T>& block)
{
- return m_storage.size() ? &m_storage[0] : 0;
+ btAssert(rowend+1-rowstart == block.rows());
+ btAssert(colend+1-colstart == block.cols());
+ for (int row=0;row<block.rows();row++)
+ {
+ for (int col=0;col<block.cols();col++)
+ {
+ setElem(rowstart+row,colstart+col,block[row]);
+ }
+ }
}
-
- const T* getBufferPointer() const
+
+
+ btMatrixX negative()
{
- return m_storage.size() ? &m_storage[0] : 0;
+ btMatrixX neg(rows(),cols());
+ for (int i=0;i<rows();i++)
+ for (int j=0;j<cols();j++)
+ {
+ T v = (*this)(i,j);
+ neg.setElem(i,j,-v);
+ }
+ return neg;
}
};
-/*
-template <typename T>
-void setElem(btMatrixX<T>& mat, int row, int col, T val)
-{
- mat.setElem(row,col,val);
-}
-*/
+
typedef btMatrixX<float> btMatrixXf;
@@ -480,6 +488,47 @@ typedef btMatrixX<double> btMatrixXd;
typedef btVectorX<double> btVectorXd;
+#ifdef BT_DEBUG_OSTREAM
+template <typename T>
+std::ostream& operator<< (std::ostream& os, const btMatrixX<T>& mat)
+ {
+
+ os << " [";
+ //printf("%s ---------------------\n",msg);
+ for (int i=0;i<mat.rows();i++)
+ {
+ for (int j=0;j<mat.cols();j++)
+ {
+ os << std::setw(12) << mat(i,j);
+ }
+ if (i!=mat.rows()-1)
+ os << std::endl << " ";
+ }
+ os << " ]";
+ //printf("\n---------------------\n");
+
+ return os;
+ }
+template <typename T>
+std::ostream& operator<< (std::ostream& os, const btVectorX<T>& mat)
+ {
+
+ os << " [";
+ //printf("%s ---------------------\n",msg);
+ for (int i=0;i<mat.rows();i++)
+ {
+ os << std::setw(12) << mat[i];
+ if (i!=mat.rows()-1)
+ os << std::endl << " ";
+ }
+ os << " ]";
+ //printf("\n---------------------\n");
+
+ return os;
+ }
+
+#endif //BT_DEBUG_OSTREAM
+
inline void setElem(btMatrixXd& mat, int row, int col, double val)
{
diff --git a/extern/bullet2/src/LinearMath/btScalar.h b/extern/bullet2/src/LinearMath/btScalar.h
index 37c6dec191d..401e11eaaa8 100644
--- a/extern/bullet2/src/LinearMath/btScalar.h
+++ b/extern/bullet2/src/LinearMath/btScalar.h
@@ -284,6 +284,10 @@ static int btNanMask = 0x7F800001;
#ifndef BT_INFINITY
static int btInfinityMask = 0x7F800000;
#define BT_INFINITY (*(float*)&btInfinityMask)
+inline int btGetInfinityMask()//suppress stupid compiler warning
+{
+ return btInfinityMask;
+}
#endif
//use this, in case there are clashes (such as xnamath.h)
@@ -336,6 +340,10 @@ inline __m128 operator * (const __m128 A, const __m128 B)
#ifndef BT_INFINITY
static int btInfinityMask = 0x7F800000;
#define BT_INFINITY (*(float*)&btInfinityMask)
+ inline int btGetInfinityMask()//suppress stupid compiler warning
+ {
+ return btInfinityMask;
+ }
#endif
#endif//BT_USE_NEON
@@ -432,7 +440,7 @@ SIMD_FORCE_INLINE btScalar btFmod(btScalar x,btScalar y) { return fmodf(x,y); }
#endif
#define SIMD_PI btScalar(3.1415926535897932384626433832795029)
-#define SIMD_2_PI btScalar(2.0) * SIMD_PI
+#define SIMD_2_PI (btScalar(2.0) * SIMD_PI)
#define SIMD_HALF_PI (SIMD_PI * btScalar(0.5))
#define SIMD_RADS_PER_DEG (SIMD_2_PI / btScalar(360.0))
#define SIMD_DEGS_PER_RAD (btScalar(360.0) / SIMD_2_PI)
@@ -728,4 +736,5 @@ template <typename T>T* btAlignPointer(T* unalignedPtr, size_t alignment)
return converter.ptr;
}
+
#endif //BT_SCALAR_H
diff --git a/extern/bullet2/src/LinearMath/btVector3.cpp b/extern/bullet2/src/LinearMath/btVector3.cpp
index a84f7baee2e..2ba7029c9be 100644
--- a/extern/bullet2/src/LinearMath/btVector3.cpp
+++ b/extern/bullet2/src/LinearMath/btVector3.cpp
@@ -821,6 +821,7 @@ long _mindot_large( const float *vv, const float *vec, unsigned long count, floa
#elif defined BT_USE_NEON
+
#define ARM_NEON_GCC_COMPATIBILITY 1
#include <arm_neon.h>
#include <sys/types.h>
@@ -884,7 +885,12 @@ static long _mindot_large_sel( const float *vv, const float *vec, unsigned long
-#define vld1q_f32_aligned_postincrement( _ptr ) ({ float32x4_t _r; asm( "vld1.f32 {%0}, [%1, :128]!\n" : "=w" (_r), "+r" (_ptr) ); /*return*/ _r; })
+#if defined __arm__
+# define vld1q_f32_aligned_postincrement( _ptr ) ({ float32x4_t _r; asm( "vld1.f32 {%0}, [%1, :128]!\n" : "=w" (_r), "+r" (_ptr) ); /*return*/ _r; })
+#else
+//support 64bit arm
+# define vld1q_f32_aligned_postincrement( _ptr) ({ float32x4_t _r = ((float32x4_t*)(_ptr))[0]; (_ptr) = (const float*) ((const char*)(_ptr) + 16L); /*return*/ _r; })
+#endif
long _maxdot_large_v0( const float *vv, const float *vec, unsigned long count, float *dotResult )
diff --git a/extern/bullet2/src/LinearMath/btVector3.h b/extern/bullet2/src/LinearMath/btVector3.h
index 89685929288..112b70dd66b 100644
--- a/extern/bullet2/src/LinearMath/btVector3.h
+++ b/extern/bullet2/src/LinearMath/btVector3.h
@@ -297,7 +297,7 @@ public:
SIMD_FORCE_INLINE btVector3& normalize()
{
- btAssert(length() != btScalar(0));
+ btAssert(!fuzzyZero());
#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
// dot product first
@@ -685,9 +685,10 @@ public:
return m_floats[0] == btScalar(0) && m_floats[1] == btScalar(0) && m_floats[2] == btScalar(0);
}
+
SIMD_FORCE_INLINE bool fuzzyZero() const
{
- return length2() < SIMD_EPSILON;
+ return length2() < SIMD_EPSILON*SIMD_EPSILON;
}
SIMD_FORCE_INLINE void serialize(struct btVector3Data& dataOut) const;
@@ -950,9 +951,9 @@ SIMD_FORCE_INLINE btScalar btVector3::distance(const btVector3& v) const
SIMD_FORCE_INLINE btVector3 btVector3::normalized() const
{
- btVector3 norm = *this;
+ btVector3 nrm = *this;
- return norm.normalize();
+ return nrm.normalize();
}
SIMD_FORCE_INLINE btVector3 btVector3::rotate( const btVector3& wAxis, const btScalar _angle ) const
@@ -1010,21 +1011,21 @@ SIMD_FORCE_INLINE long btVector3::maxDot( const btVector3 *array, long arra
if( array_count < scalar_cutoff )
#endif
{
- btScalar maxDot = -SIMD_INFINITY;
+ btScalar maxDot1 = -SIMD_INFINITY;
int i = 0;
int ptIndex = -1;
for( i = 0; i < array_count; i++ )
{
btScalar dot = array[i].dot(*this);
- if( dot > maxDot )
+ if( dot > maxDot1 )
{
- maxDot = dot;
+ maxDot1 = dot;
ptIndex = i;
}
}
- dotOut = maxDot;
+ dotOut = maxDot1;
return ptIndex;
}
#if (defined BT_USE_SSE && defined BT_USE_SIMD_VECTOR3 && defined BT_USE_SSE_IN_API) || defined (BT_USE_NEON)
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 8f81e93f7c8..83483cbcae9 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1172,13 +1172,12 @@ class CyclesRender_PT_CurveRendering(CyclesButtonsPanel, Panel):
layout.prop(ccscene, "primitive", text="Primitive")
layout.prop(ccscene, "shape", text="Shape")
- if ccscene.primitive == 'TRIANGLES':
- if ccscene.shape == 'THICK':
- layout.prop(ccscene, "resolution", text="Resolution")
- elif ccscene.primitive == 'LINE_SEGMENTS':
- layout.prop(ccscene, "cull_backfacing", text="Cull back-faces")
- elif ccscene.primitive in {'CURVE_SEGMENTS', 'CURVE_RIBBONS'}:
+ if (ccscene.primitive in {'CURVE_SEGMENTS', 'LINE_SEGMENTS'} and ccscene.shape == 'RIBBONS') == False:
layout.prop(ccscene, "cull_backfacing", text="Cull back-faces")
+
+ if ccscene.primitive == 'TRIANGLES' and ccscene.shape == 'THICK':
+ layout.prop(ccscene, "resolution", text="Resolution")
+ elif ccscene.primitive == 'CURVE_SEGMENTS':
layout.prop(ccscene, "subdivisions", text="Curve subdivisions")
row = layout.row()
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index c47f410a742..7e8eb3aa374 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -701,25 +701,23 @@ void BlenderSync::sync_curve_settings()
curve_system_manager->triangle_method = CURVE_CAMERA_TRIANGLES;
curve_system_manager->resolution = 1;
}
- if(curve_system_manager->primitive == CURVE_TRIANGLES && curve_system_manager->curve_shape == CURVE_THICK) {
+ else if(curve_system_manager->primitive == CURVE_TRIANGLES && curve_system_manager->curve_shape == CURVE_THICK) {
/* camera facing planes */
curve_system_manager->triangle_method = CURVE_TESSELATED_TRIANGLES;
}
- if(curve_system_manager->primitive == CURVE_LINE_SEGMENTS && curve_system_manager->curve_shape == CURVE_RIBBON) {
+ else if(curve_system_manager->primitive == CURVE_LINE_SEGMENTS && curve_system_manager->curve_shape == CURVE_RIBBON) {
/* tangent shading */
curve_system_manager->line_method = CURVE_UNCORRECTED;
curve_system_manager->use_encasing = true;
curve_system_manager->use_backfacing = false;
- curve_system_manager->use_tangent_normal = true;
curve_system_manager->use_tangent_normal_geometry = true;
}
- if(curve_system_manager->primitive == CURVE_LINE_SEGMENTS && curve_system_manager->curve_shape == CURVE_THICK) {
+ else if(curve_system_manager->primitive == CURVE_LINE_SEGMENTS && curve_system_manager->curve_shape == CURVE_THICK) {
curve_system_manager->line_method = CURVE_ACCURATE;
curve_system_manager->use_encasing = false;
- curve_system_manager->use_tangent_normal = false;
curve_system_manager->use_tangent_normal_geometry = false;
}
- if(curve_system_manager->primitive == CURVE_SEGMENTS && curve_system_manager->curve_shape == CURVE_RIBBON) {
+ else if(curve_system_manager->primitive == CURVE_SEGMENTS && curve_system_manager->curve_shape == CURVE_RIBBON) {
curve_system_manager->primitive = CURVE_RIBBONS;
curve_system_manager->use_backfacing = false;
}
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 3a88b68b292..9117b70d749 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -931,7 +931,7 @@ public:
size_t global_size[2] = {global_size_round_up(local_size[0], w), global_size_round_up(local_size[1], h)};
/* run kernel */
- ciErr = clEnqueueNDRangeKernel(cqCommandQueue, kernel, 2, NULL, global_size, local_size, 0, NULL, NULL);
+ ciErr = clEnqueueNDRangeKernel(cqCommandQueue, kernel, 2, NULL, global_size, NULL, 0, NULL, NULL);
opencl_assert(ciErr);
opencl_assert(clFlush(cqCommandQueue));
}
diff --git a/intern/cycles/kernel/kernel_bvh.h b/intern/cycles/kernel/kernel_bvh.h
index dc31e72b896..c1595f64e0d 100644
--- a/intern/cycles/kernel/kernel_bvh.h
+++ b/intern/cycles/kernel/kernel_bvh.h
@@ -406,17 +406,12 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
coverage = (min(d1 / mw_extension, 1.0f) + min(-d0 / mw_extension, 1.0f)) * 0.5f;
}
- if (p_curr.x * p_curr.x + p_curr.y * p_curr.y >= r_ext * r_ext || p_curr.z <= epsilon) {
- tree++;
- level = tree & -tree;
- continue;
- }
- /* compare z distances */
- if (isect->t < p_curr.z) {
+ if (p_curr.x * p_curr.x + p_curr.y * p_curr.y >= r_ext * r_ext || p_curr.z <= epsilon || isect->t < p_curr.z) {
tree++;
level = tree & -tree;
continue;
}
+
t = p_curr.z;
}
else {
@@ -453,7 +448,6 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
float rootd = sqrtf(td);
float correction = ((-tb - rootd)/(2*cyla));
t = tcentre + correction;
- float w = (zcentre + (tg.z * correction))/l;
float3 dp_st = (3 * curve_coef[3] * i_st + 2 * curve_coef[2]) * i_st + curve_coef[1];
if (dot(tg, dp_st)< 0)
@@ -462,11 +456,9 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
if (dot(tg, dp_en) < 0)
dp_en *= -1;
-
if(flags & CURVE_KN_BACKFACING && (dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f)) {
correction = ((-tb + rootd)/(2*cyla));
t = tcentre + correction;
- w = (zcentre + (tg.z * correction))/l;
}
if (dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f) {
@@ -475,6 +467,7 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
continue;
}
+ float w = (zcentre + (tg.z * correction))/l;
w = clamp((float)w, 0.0f, 1.0f);
/* compute u on the curve segment */
u = i_st * (1 - w) + i_en * w;
@@ -1099,7 +1092,7 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
float4 P1 = kernel_tex_fetch(__curve_keys, k0);
float4 P2 = kernel_tex_fetch(__curve_keys, k1);
float l = 1.0f;
- float3 tg = normalize_len(float4_to_float3(P2 - P1),&l);
+ float3 tg = normalize_len(float4_to_float3(P2 - P1), &l);
float r1 = P1.w;
float r2 = P2.w;
float gd = ((r2 - r1)/l);
@@ -1119,17 +1112,17 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
p[2] = float4_to_float3(P2);
p[3] = float4_to_float3(P3);
- tg = normalize(curvetangent(isect->u,p[0],p[1],p[2],p[3]));
- float3 p_curr = curvepoint(isect->u,p[0],p[1],p[2],p[3]);
-
#ifdef __UV__
sd->u = isect->u;
sd->v = 0.0f;
#endif
+
+ tg = normalize(curvetangent(isect->u, p[0], p[1], p[2], p[3]));
if(kernel_data.curve.curveflags & CURVE_KN_RIBBONS)
- sd->Ng = normalize(-(D - tg * (dot(tg,D))));
+ sd->Ng = normalize(-(D - tg * (dot(tg, D))));
else {
+ float3 p_curr = curvepoint(isect->u, p[0], p[1], p[2], p[3]);
sd->Ng = normalize(P - p_curr);
sd->Ng = sd->Ng - gd * tg;
sd->Ng = normalize(sd->Ng);
@@ -1145,7 +1138,7 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
#endif
if (flag & CURVE_KN_TRUETANGENTGNORMAL) {
- sd->Ng = -(D - tg * dot(tg,D));
+ sd->Ng = -(D - tg * dot(tg, D));
sd->Ng = normalize(sd->Ng);
}
else {
@@ -1157,24 +1150,12 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
}
sd->N = sd->Ng;
-
- if (flag & CURVE_KN_TANGENTGNORMAL && !(flag & CURVE_KN_TRUETANGENTGNORMAL)) {
- sd->N = -(D - tg * dot(tg,D));
- sd->N = normalize(sd->N);
- }
- if (!(flag & CURVE_KN_TANGENTGNORMAL) && flag & CURVE_KN_TRUETANGENTGNORMAL) {
- sd->N = (dif - tg * sd->u * l) / (P1.w + sd->u * l * gd);
- if (gd != 0.0f) {
- sd->N = sd->N - gd * tg ;
- sd->N = normalize(sd->N);
- }
- }
}
#ifdef __DPDU__
/* dPdu/dPdv */
sd->dPdu = tg;
- sd->dPdv = cross(tg,sd->Ng);
+ sd->dPdv = cross(tg, sd->Ng);
#endif
/*add fading parameter for minimum pixel width with transparency bsdf*/
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index fb63ebb2e7a..9b1893e8baa 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -792,8 +792,7 @@ typedef enum CurveFlag {
CURVE_KN_ACCURATE = 8, /* use accurate intersections test? */
CURVE_KN_INTERSECTCORRECTION = 16, /* correct for width after determing closest midpoint? */
CURVE_KN_TRUETANGENTGNORMAL = 32, /* use tangent normal for geometry? */
- CURVE_KN_TANGENTGNORMAL = 64, /* use tangent normal for shader? */
- CURVE_KN_RIBBONS = 128, /* use flat curve ribbons */
+ CURVE_KN_RIBBONS = 64, /* use flat curve ribbons */
} CurveFlag;
typedef struct KernelCurves {
diff --git a/intern/cycles/render/curves.cpp b/intern/cycles/render/curves.cpp
index 4e7f598751e..574ad4f6ca0 100644
--- a/intern/cycles/render/curves.cpp
+++ b/intern/cycles/render/curves.cpp
@@ -92,7 +92,6 @@ CurveSystemManager::CurveSystemManager()
use_curves = true;
use_encasing = true;
use_backfacing = false;
- use_tangent_normal = false;
use_tangent_normal_geometry = false;
need_update = true;
@@ -127,8 +126,6 @@ void CurveSystemManager::device_update(Device *device, DeviceScene *dscene, Scen
else if(line_method == CURVE_CORRECTED)
kcurve->curveflags |= CURVE_KN_INTERSECTCORRECTION;
- if(use_tangent_normal)
- kcurve->curveflags |= CURVE_KN_TANGENTGNORMAL;
if(use_tangent_normal_geometry)
kcurve->curveflags |= CURVE_KN_TRUETANGENTGNORMAL;
if(use_backfacing)
@@ -158,7 +155,6 @@ bool CurveSystemManager::modified(const CurveSystemManager& CurveSystemManager)
line_method == CurveSystemManager.line_method &&
primitive == CurveSystemManager.primitive &&
use_encasing == CurveSystemManager.use_encasing &&
- use_tangent_normal == CurveSystemManager.use_tangent_normal &&
use_tangent_normal_geometry == CurveSystemManager.use_tangent_normal_geometry &&
encasing_ratio == CurveSystemManager.encasing_ratio &&
minimum_width == CurveSystemManager.minimum_width &&
diff --git a/intern/cycles/render/curves.h b/intern/cycles/render/curves.h
index 0759d495561..8020a93e77e 100644
--- a/intern/cycles/render/curves.h
+++ b/intern/cycles/render/curves.h
@@ -97,7 +97,6 @@ public:
bool use_curves;
bool use_encasing;
bool use_backfacing;
- bool use_tangent_normal;
bool use_tangent_normal_geometry;
bool need_update;
diff --git a/intern/rigidbody/RBI_api.h b/intern/rigidbody/RBI_api.h
index 7a04961f99d..688ca91c774 100644
--- a/intern/rigidbody/RBI_api.h
+++ b/intern/rigidbody/RBI_api.h
@@ -73,26 +73,26 @@ typedef struct rbConstraint rbConstraint;
/* Create a new dynamics world instance */
// TODO: add args to set the type of constraint solvers, etc.
-extern rbDynamicsWorld *RB_dworld_new(const float gravity[3]);
+rbDynamicsWorld *RB_dworld_new(const float gravity[3]);
/* Delete the given dynamics world, and free any extra data it may require */
-extern void RB_dworld_delete(rbDynamicsWorld *world);
+void RB_dworld_delete(rbDynamicsWorld *world);
/* Settings ------------------------- */
/* Gravity */
-extern void RB_dworld_get_gravity(rbDynamicsWorld *world, float g_out[3]);
-extern void RB_dworld_set_gravity(rbDynamicsWorld *world, const float g_in[3]);
+void RB_dworld_get_gravity(rbDynamicsWorld *world, float g_out[3]);
+void RB_dworld_set_gravity(rbDynamicsWorld *world, const float g_in[3]);
/* Constraint Solver */
-extern void RB_dworld_set_solver_iterations(rbDynamicsWorld *world, int num_solver_iterations);
+void RB_dworld_set_solver_iterations(rbDynamicsWorld *world, int num_solver_iterations);
/* Split Impulse */
-extern void RB_dworld_set_split_impulse(rbDynamicsWorld *world, int split_impulse);
+void RB_dworld_set_split_impulse(rbDynamicsWorld *world, int split_impulse);
/* Simulation ----------------------- */
/* Step the simulation by the desired amount (in seconds) with extra controls on substep sizes and maximum substeps */
-extern void RB_dworld_step_simulation(rbDynamicsWorld *world, float timeStep, int maxSubSteps, float timeSubStep);
+void RB_dworld_step_simulation(rbDynamicsWorld *world, float timeStep, int maxSubSteps, float timeSubStep);
/* Export -------------------------- */
@@ -105,98 +105,99 @@ void RB_dworld_export(rbDynamicsWorld *world, const char *filename);
/* Setup ---------------------------- */
/* Add RigidBody to dynamics world */
-extern void RB_dworld_add_body(rbDynamicsWorld *world, rbRigidBody *body, int col_groups);
+void RB_dworld_add_body(rbDynamicsWorld *world, rbRigidBody *body, int col_groups);
/* Remove RigidBody from dynamics world */
-extern void RB_dworld_remove_body(rbDynamicsWorld *world, rbRigidBody *body);
+void RB_dworld_remove_body(rbDynamicsWorld *world, rbRigidBody *body);
/* Collision detection */
-void RB_world_convex_sweep_test(rbDynamicsWorld *world, rbRigidBody *object,
- const float loc_start[3], const float loc_end[3],
- float v_location[3], float v_hitpoint[3], float v_normal[3], int *r_hit);
+void RB_world_convex_sweep_test(
+ rbDynamicsWorld *world, rbRigidBody *object,
+ const float loc_start[3], const float loc_end[3],
+ float v_location[3], float v_hitpoint[3], float v_normal[3], int *r_hit);
/* ............ */
/* Create new RigidBody instance */
-extern rbRigidBody *RB_body_new(rbCollisionShape *shape, const float loc[3], const float rot[4]);
+rbRigidBody *RB_body_new(rbCollisionShape *shape, const float loc[3], const float rot[4]);
/* Delete the given RigidBody instance */
-extern void RB_body_delete(rbRigidBody *body);
+void RB_body_delete(rbRigidBody *body);
/* Settings ------------------------- */
/* 'Type' */
-extern void RB_body_set_type(rbRigidBody *body, int type, float mass);
+void RB_body_set_type(rbRigidBody *body, int type, float mass);
/* ............ */
/* Collision Shape */
-extern void RB_body_set_collision_shape(rbRigidBody *body, rbCollisionShape *shape);
+void RB_body_set_collision_shape(rbRigidBody *body, rbCollisionShape *shape);
/* ............ */
/* Mass */
-extern float RB_body_get_mass(rbRigidBody *body);
-extern void RB_body_set_mass(rbRigidBody *body, float value);
+float RB_body_get_mass(rbRigidBody *body);
+void RB_body_set_mass(rbRigidBody *body, float value);
/* Friction */
-extern float RB_body_get_friction(rbRigidBody *body);
-extern void RB_body_set_friction(rbRigidBody *body, float value);
+float RB_body_get_friction(rbRigidBody *body);
+void RB_body_set_friction(rbRigidBody *body, float value);
/* Restitution */
-extern float RB_body_get_restitution(rbRigidBody *body);
-extern void RB_body_set_restitution(rbRigidBody *body, float value);
+float RB_body_get_restitution(rbRigidBody *body);
+void RB_body_set_restitution(rbRigidBody *body, float value);
/* Damping */
-extern float RB_body_get_linear_damping(rbRigidBody *body);
-extern void RB_body_set_linear_damping(rbRigidBody *body, float value);
+float RB_body_get_linear_damping(rbRigidBody *body);
+void RB_body_set_linear_damping(rbRigidBody *body, float value);
-extern float RB_body_get_angular_damping(rbRigidBody *body);
-extern void RB_body_set_angular_damping(rbRigidBody *body, float value);
+float RB_body_get_angular_damping(rbRigidBody *body);
+void RB_body_set_angular_damping(rbRigidBody *body, float value);
-extern void RB_body_set_damping(rbRigidBody *object, float linear, float angular);
+void RB_body_set_damping(rbRigidBody *object, float linear, float angular);
/* Sleeping Thresholds */
-extern float RB_body_get_linear_sleep_thresh(rbRigidBody *body);
-extern void RB_body_set_linear_sleep_thresh(rbRigidBody *body, float value);
+float RB_body_get_linear_sleep_thresh(rbRigidBody *body);
+void RB_body_set_linear_sleep_thresh(rbRigidBody *body, float value);
-extern float RB_body_get_angular_sleep_thresh(rbRigidBody *body);
-extern void RB_body_set_angular_sleep_thresh(rbRigidBody *body, float value);
+float RB_body_get_angular_sleep_thresh(rbRigidBody *body);
+void RB_body_set_angular_sleep_thresh(rbRigidBody *body, float value);
-extern void RB_body_set_sleep_thresh(rbRigidBody *body, float linear, float angular);
+void RB_body_set_sleep_thresh(rbRigidBody *body, float linear, float angular);
/* Linear Velocity */
-extern void RB_body_get_linear_velocity(rbRigidBody *body, float v_out[3]);
-extern void RB_body_set_linear_velocity(rbRigidBody *body, const float v_in[3]);
+void RB_body_get_linear_velocity(rbRigidBody *body, float v_out[3]);
+void RB_body_set_linear_velocity(rbRigidBody *body, const float v_in[3]);
/* Angular Velocity */
-extern void RB_body_get_angular_velocity(rbRigidBody *body, float v_out[3]);
-extern void RB_body_set_angular_velocity(rbRigidBody *body, const float v_in[3]);
+void RB_body_get_angular_velocity(rbRigidBody *body, float v_out[3]);
+void RB_body_set_angular_velocity(rbRigidBody *body, const float v_in[3]);
/* Linear/Angular Factor, used to lock translation/roation axes */
-extern void RB_body_set_linear_factor(rbRigidBody *object, float x, float y, float z);
-extern void RB_body_set_angular_factor(rbRigidBody *object, float x, float y, float z);
+void RB_body_set_linear_factor(rbRigidBody *object, float x, float y, float z);
+void RB_body_set_angular_factor(rbRigidBody *object, float x, float y, float z);
/* Kinematic State */
-extern void RB_body_set_kinematic_state(rbRigidBody *body, int kinematic);
+void RB_body_set_kinematic_state(rbRigidBody *body, int kinematic);
/* RigidBody Interface - Rigid Body Activation States */
-extern int RB_body_get_activation_state(rbRigidBody *body);
-extern void RB_body_set_activation_state(rbRigidBody *body, int use_deactivation);
-extern void RB_body_activate(rbRigidBody *body);
-extern void RB_body_deactivate(rbRigidBody *body);
+int RB_body_get_activation_state(rbRigidBody *body);
+void RB_body_set_activation_state(rbRigidBody *body, int use_deactivation);
+void RB_body_activate(rbRigidBody *body);
+void RB_body_deactivate(rbRigidBody *body);
/* Simulation ----------------------- */
/* Get current transform matrix of RigidBody to use in Blender (OpenGL format) */
-extern void RB_body_get_transform_matrix(rbRigidBody *body, float m_out[4][4]);
+void RB_body_get_transform_matrix(rbRigidBody *body, float m_out[4][4]);
/* Set RigidBody's location and rotation */
-extern void RB_body_set_loc_rot(rbRigidBody *body, const float loc[3], const float rot[4]);
+void RB_body_set_loc_rot(rbRigidBody *body, const float loc[3], const float rot[4]);
/* Set RigidBody's local scaling */
-extern void RB_body_set_scale(rbRigidBody *body, const float scale[3]);
+void RB_body_set_scale(rbRigidBody *body, const float scale[3]);
/* ............ */
@@ -207,43 +208,47 @@ void RB_body_get_orientation(rbRigidBody *body, float v_out[4]);
/* ............ */
-extern void RB_body_apply_central_force(rbRigidBody *body, const float v_in[3]);
+void RB_body_apply_central_force(rbRigidBody *body, const float v_in[3]);
/* ********************************** */
/* Collision Shape Methods */
/* Setup (Standard Shapes) ----------- */
-extern rbCollisionShape *RB_shape_new_box(float x, float y, float z);
-extern rbCollisionShape *RB_shape_new_sphere(float radius);
-extern rbCollisionShape *RB_shape_new_capsule(float radius, float height);
-extern rbCollisionShape *RB_shape_new_cone(float radius, float height);
-extern rbCollisionShape *RB_shape_new_cylinder(float radius, float height);
+rbCollisionShape *RB_shape_new_box(float x, float y, float z);
+rbCollisionShape *RB_shape_new_sphere(float radius);
+rbCollisionShape *RB_shape_new_capsule(float radius, float height);
+rbCollisionShape *RB_shape_new_cone(float radius, float height);
+rbCollisionShape *RB_shape_new_cylinder(float radius, float height);
/* Setup (Convex Hull) ------------ */
-extern rbCollisionShape *RB_shape_new_convex_hull(float *verts, int stride, int count, float margin, bool *can_embed);
+rbCollisionShape *RB_shape_new_convex_hull(float *verts, int stride, int count, float margin, bool *can_embed);
/* Setup (Triangle Mesh) ---------- */
/* 1 */
-extern rbMeshData *RB_trimesh_data_new(void);
-extern void RB_trimesh_add_triangle(rbMeshData *mesh, const float v1[3], const float v2[3], const float v3[3]);
+rbMeshData *RB_trimesh_data_new(int num_tris, int num_verts);
+void RB_trimesh_add_vertices(rbMeshData *mesh, float *vertices, int num_verts, int vert_stride);
+void RB_trimesh_add_triangle_indices(rbMeshData *mesh, int num, int index0, int index1, int index2);
+void RB_trimesh_finish(rbMeshData *mesh);
/* 2a - Triangle Meshes */
-extern rbCollisionShape *RB_shape_new_trimesh(rbMeshData *mesh);
+rbCollisionShape *RB_shape_new_trimesh(rbMeshData *mesh);
/* 2b - GImpact Meshes */
-extern rbCollisionShape *RB_shape_new_gimpact_mesh(rbMeshData *mesh);
+rbCollisionShape *RB_shape_new_gimpact_mesh(rbMeshData *mesh);
/* Cleanup --------------------------- */
-extern void RB_shape_delete(rbCollisionShape *shape);
+void RB_shape_delete(rbCollisionShape *shape);
/* Settings --------------------------- */
/* Collision Margin */
-extern float RB_shape_get_margin(rbCollisionShape *shape);
-extern void RB_shape_set_margin(rbCollisionShape *shape, float value);
+float RB_shape_get_margin(rbCollisionShape *shape);
+void RB_shape_set_margin(rbCollisionShape *shape, float value);
+
+void RB_shape_trimesh_update(rbCollisionShape *shape, float *vertices, int num_verts, int vert_stride, float min[3], float max[3]);
/* ********************************** */
/* Constraints */
@@ -251,30 +256,30 @@ extern void RB_shape_set_margin(rbCollisionShape *shape, float value);
/* Setup ----------------------------- */
/* Add Rigid Body Constraint to simulation world */
-extern void RB_dworld_add_constraint(rbDynamicsWorld *world, rbConstraint *con, int disable_collisions);
+void RB_dworld_add_constraint(rbDynamicsWorld *world, rbConstraint *con, int disable_collisions);
/* Remove Rigid Body Constraint from simulation world */
-extern void RB_dworld_remove_constraint(rbDynamicsWorld *world, rbConstraint *con);
+void RB_dworld_remove_constraint(rbDynamicsWorld *world, rbConstraint *con);
-extern rbConstraint *RB_constraint_new_point(float pivot[3], rbRigidBody *rb1, rbRigidBody *rb2);
-extern rbConstraint *RB_constraint_new_fixed(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
-extern rbConstraint *RB_constraint_new_hinge(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
-extern rbConstraint *RB_constraint_new_slider(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
-extern rbConstraint *RB_constraint_new_piston(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
-extern rbConstraint *RB_constraint_new_6dof(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
-extern rbConstraint *RB_constraint_new_6dof_spring(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
-extern rbConstraint *RB_constraint_new_motor(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
+rbConstraint *RB_constraint_new_point(float pivot[3], rbRigidBody *rb1, rbRigidBody *rb2);
+rbConstraint *RB_constraint_new_fixed(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
+rbConstraint *RB_constraint_new_hinge(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
+rbConstraint *RB_constraint_new_slider(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
+rbConstraint *RB_constraint_new_piston(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
+rbConstraint *RB_constraint_new_6dof(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
+rbConstraint *RB_constraint_new_6dof_spring(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
+rbConstraint *RB_constraint_new_motor(float pivot[3], float orn[4], rbRigidBody *rb1, rbRigidBody *rb2);
/* ............ */
/* Cleanup --------------------------- */
-extern void RB_constraint_delete(rbConstraint *con);
+void RB_constraint_delete(rbConstraint *con);
/* Settings --------------------------- */
/* Enable or disable constraint */
-extern void RB_constraint_set_enabled(rbConstraint *con, int enabled);
+void RB_constraint_set_enabled(rbConstraint *con, int enabled);
/* Limits */
#define RB_LIMIT_LIN_X 0
@@ -288,28 +293,28 @@ extern void RB_constraint_set_enabled(rbConstraint *con, int enabled);
* - lower limit > upper limit -> axis is free
* - lower limit < upper limit -> axis is limited in given range
*/
-extern void RB_constraint_set_limits_hinge(rbConstraint *con, float lower, float upper);
-extern void RB_constraint_set_limits_slider(rbConstraint *con, float lower, float upper);
-extern void RB_constraint_set_limits_piston(rbConstraint *con, float lin_lower, float lin_upper, float ang_lower, float ang_upper);
-extern void RB_constraint_set_limits_6dof(rbConstraint *con, int axis, float lower, float upper);
+void RB_constraint_set_limits_hinge(rbConstraint *con, float lower, float upper);
+void RB_constraint_set_limits_slider(rbConstraint *con, float lower, float upper);
+void RB_constraint_set_limits_piston(rbConstraint *con, float lin_lower, float lin_upper, float ang_lower, float ang_upper);
+void RB_constraint_set_limits_6dof(rbConstraint *con, int axis, float lower, float upper);
/* 6dof spring specific */
-extern void RB_constraint_set_stiffness_6dof_spring(rbConstraint *con, int axis, float stiffness);
-extern void RB_constraint_set_damping_6dof_spring(rbConstraint *con, int axis, float damping);
-extern void RB_constraint_set_spring_6dof_spring(rbConstraint *con, int axis, int enable);
-extern void RB_constraint_set_equilibrium_6dof_spring(rbConstraint *con);
+void RB_constraint_set_stiffness_6dof_spring(rbConstraint *con, int axis, float stiffness);
+void RB_constraint_set_damping_6dof_spring(rbConstraint *con, int axis, float damping);
+void RB_constraint_set_spring_6dof_spring(rbConstraint *con, int axis, int enable);
+void RB_constraint_set_equilibrium_6dof_spring(rbConstraint *con);
/* motors */
-extern void RB_constraint_set_enable_motor(rbConstraint *con, int enable_lin, int enable_ang);
-extern void RB_constraint_set_max_impulse_motor(rbConstraint *con, float max_impulse_lin, float max_impulse_ang);
-extern void RB_constraint_set_target_velocity_motor(rbConstraint *con, float velocity_lin, float velocity_ang);
+void RB_constraint_set_enable_motor(rbConstraint *con, int enable_lin, int enable_ang);
+void RB_constraint_set_max_impulse_motor(rbConstraint *con, float max_impulse_lin, float max_impulse_ang);
+void RB_constraint_set_target_velocity_motor(rbConstraint *con, float velocity_lin, float velocity_ang);
/* Set number of constraint solver iterations made per step, this overrided world setting
* To use default set it to -1 */
-extern void RB_constraint_set_solver_iterations(rbConstraint *con, int num_solver_iterations);
+void RB_constraint_set_solver_iterations(rbConstraint *con, int num_solver_iterations);
/* Set breaking impulse threshold, if constraint shouldn't break it can be set to FLT_MAX */
-extern void RB_constraint_set_breaking_threshold(rbConstraint *con, float threshold);
+void RB_constraint_set_breaking_threshold(rbConstraint *con, float threshold);
/* ********************************** */
diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp
index ecb07c628d2..ab7b851911a 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -86,9 +86,24 @@ struct rbRigidBody {
int col_groups;
};
+struct rbVert {
+ float x, y, z;
+};
+struct rbTri {
+ int v0, v1, v2;
+};
+
+struct rbMeshData {
+ btTriangleIndexVertexArray *index_array;
+ rbVert *vertices;
+ rbTri *triangles;
+ int num_vertices;
+ int num_triangles;
+};
+
struct rbCollisionShape {
btCollisionShape *cshape;
- btTriangleMesh *mesh;
+ rbMeshData *mesh;
};
struct rbFilterCallback : public btOverlapFilterCallback
@@ -250,7 +265,10 @@ void RB_dworld_remove_body(rbDynamicsWorld *world, rbRigidBody *object)
/* Collision detection */
-void RB_world_convex_sweep_test(rbDynamicsWorld *world, rbRigidBody *object, const float loc_start[3], const float loc_end[3], float v_location[3], float v_hitpoint[3], float v_normal[3], int *r_hit)
+void RB_world_convex_sweep_test(
+ rbDynamicsWorld *world, rbRigidBody *object,
+ const float loc_start[3], const float loc_end[3],
+ float v_location[3], float v_hitpoint[3], float v_normal[3], int *r_hit)
{
btRigidBody *body = object->body;
btCollisionShape *collisionShape = body->getCollisionShape();
@@ -270,14 +288,14 @@ void RB_world_convex_sweep_test(rbDynamicsWorld *world, rbRigidBody *object, con
rayToTrans.setRotation(obRot);
rayToTrans.setOrigin(btVector3(loc_end[0], loc_end[1], loc_end[2]));
- world->dynamicsWorld->convexSweepTest((btConvexShape*) collisionShape, rayFromTrans, rayToTrans, result, 0);
+ world->dynamicsWorld->convexSweepTest((btConvexShape *)collisionShape, rayFromTrans, rayToTrans, result, 0);
if (result.hasHit()) {
*r_hit = 1;
- v_location[0] = result.m_convexFromWorld[0]+(result.m_convexToWorld[0]-result.m_convexFromWorld[0])*result.m_closestHitFraction;
- v_location[1] = result.m_convexFromWorld[1]+(result.m_convexToWorld[1]-result.m_convexFromWorld[1])*result.m_closestHitFraction;
- v_location[2] = result.m_convexFromWorld[2]+(result.m_convexToWorld[2]-result.m_convexFromWorld[2])*result.m_closestHitFraction;
+ v_location[0] = result.m_convexFromWorld[0] + (result.m_convexToWorld[0] - result.m_convexFromWorld[0]) * result.m_closestHitFraction;
+ v_location[1] = result.m_convexFromWorld[1] + (result.m_convexToWorld[1] - result.m_convexFromWorld[1]) * result.m_closestHitFraction;
+ v_location[2] = result.m_convexFromWorld[2] + (result.m_convexToWorld[2] - result.m_convexFromWorld[2]) * result.m_closestHitFraction;
v_hitpoint[0] = result.m_hitPointWorld[0];
v_hitpoint[1] = result.m_hitPointWorld[1];
@@ -292,7 +310,7 @@ void RB_world_convex_sweep_test(rbDynamicsWorld *world, rbRigidBody *object, con
*r_hit = 0;
}
}
- else{
+ else {
/* we need to return a value if user passes non convex body, to report */
*r_hit = -2;
}
@@ -692,57 +710,94 @@ rbCollisionShape *RB_shape_new_convex_hull(float *verts, int stride, int count,
/* Setup (Triangle Mesh) ---------- */
-/* Need to call rbTriMeshNewData() followed by rbTriMeshAddTriangle() several times
- * to set up the mesh buffer BEFORE calling rbShapeNewTriMesh(). Otherwise,
- * we get nasty crashes...
- */
+/* Need to call RB_trimesh_finish() after creating triangle mesh and adding vertices and triangles */
-rbMeshData *RB_trimesh_data_new()
+rbMeshData *RB_trimesh_data_new(int num_tris, int num_verts)
{
- // XXX: welding threshold?
- return (rbMeshData *) new btTriangleMesh(true, false);
+ rbMeshData *mesh = new rbMeshData;
+ mesh->vertices = new rbVert[num_verts];
+ mesh->triangles = new rbTri[num_tris];
+ mesh->num_vertices = num_verts;
+ mesh->num_triangles = num_tris;
+
+ return mesh;
+}
+
+static void RB_trimesh_data_delete(rbMeshData *mesh)
+{
+ delete mesh->index_array;
+ delete mesh->vertices;
+ delete mesh->triangles;
+ delete mesh;
}
-void RB_trimesh_add_triangle(rbMeshData *mesh, const float v1[3], const float v2[3], const float v3[3])
+void RB_trimesh_add_vertices(rbMeshData *mesh, float *vertices, int num_verts, int vert_stride)
{
- btTriangleMesh *meshData = reinterpret_cast<btTriangleMesh*>(mesh);
-
- /* cast vertices to usable forms for Bt-API */
- btVector3 vtx1((btScalar)v1[0], (btScalar)v1[1], (btScalar)v1[2]);
- btVector3 vtx2((btScalar)v2[0], (btScalar)v2[1], (btScalar)v2[2]);
- btVector3 vtx3((btScalar)v3[0], (btScalar)v3[1], (btScalar)v3[2]);
-
- /* add to the mesh
- * - remove duplicated verts is enabled
- */
- meshData->addTriangle(vtx1, vtx2, vtx3, false);
+ for (int i = 0; i < num_verts; i++) {
+ float *vert = (float*)(((char*)vertices + i * vert_stride));
+ mesh->vertices[i].x = vert[0];
+ mesh->vertices[i].y = vert[1];
+ mesh->vertices[i].z = vert[2];
+ }
+}
+void RB_trimesh_add_triangle_indices(rbMeshData *mesh, int num, int index0, int index1, int index2)
+{
+ mesh->triangles[num].v0 = index0;
+ mesh->triangles[num].v1 = index1;
+ mesh->triangles[num].v2 = index2;
+}
+
+void RB_trimesh_finish(rbMeshData *mesh)
+{
+ mesh->index_array = new btTriangleIndexVertexArray(mesh->num_triangles, (int*)mesh->triangles, sizeof(rbTri),
+ mesh->num_vertices, (float*)mesh->vertices, sizeof(rbVert));
}
rbCollisionShape *RB_shape_new_trimesh(rbMeshData *mesh)
{
rbCollisionShape *shape = new rbCollisionShape;
- btTriangleMesh *tmesh = reinterpret_cast<btTriangleMesh*>(mesh);
/* triangle-mesh we create is a BVH wrapper for triangle mesh data (for faster lookups) */
// RB_TODO perhaps we need to allow saving out this for performance when rebuilding?
- btBvhTriangleMeshShape *unscaledShape = new btBvhTriangleMeshShape(tmesh, true, true);
+ btBvhTriangleMeshShape *unscaledShape = new btBvhTriangleMeshShape(mesh->index_array, true, true);
shape->cshape = new btScaledBvhTriangleMeshShape(unscaledShape, btVector3(1.0f, 1.0f, 1.0f));
- shape->mesh = tmesh;
+ shape->mesh = mesh;
return shape;
}
+void RB_shape_trimesh_update(rbCollisionShape *shape, float *vertices, int num_verts, int vert_stride, float min[3], float max[3])
+{
+ if (shape->mesh == NULL || num_verts != shape->mesh->num_vertices)
+ return;
+
+ for (int i = 0; i < num_verts; i++) {
+ float *vert = (float*)(((char*)vertices + i * vert_stride));
+ shape->mesh->vertices[i].x = vert[0];
+ shape->mesh->vertices[i].y = vert[1];
+ shape->mesh->vertices[i].z = vert[2];
+ }
+
+ if (shape->cshape->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE) {
+ btScaledBvhTriangleMeshShape *scaled_shape = (btScaledBvhTriangleMeshShape *)shape->cshape;
+ btBvhTriangleMeshShape *mesh_shape = scaled_shape->getChildShape();
+ mesh_shape->refitTree(btVector3(min[0], min[1], min[2]), btVector3(max[0], max[1], max[2]));
+ }
+ else if (shape->cshape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE) {
+ btGImpactMeshShape *mesh_shape = (btGImpactMeshShape*)shape->cshape;
+ mesh_shape->updateBound();
+ }
+}
+
rbCollisionShape *RB_shape_new_gimpact_mesh(rbMeshData *mesh)
{
rbCollisionShape *shape = new rbCollisionShape;
- /* interpret mesh buffer as btTriangleIndexVertexArray (i.e. an impl of btStridingMeshInterface) */
- btTriangleMesh *tmesh = reinterpret_cast<btTriangleMesh*>(mesh);
- btGImpactMeshShape *gimpactShape = new btGImpactMeshShape(tmesh);
+ btGImpactMeshShape *gimpactShape = new btGImpactMeshShape(mesh->index_array);
gimpactShape->updateBound(); // TODO: add this to the update collision margin call?
shape->cshape = gimpactShape;
- shape->mesh = tmesh;
+ shape->mesh = mesh;
return shape;
}
@@ -756,7 +811,7 @@ void RB_shape_delete(rbCollisionShape *shape)
delete child_shape;
}
if (shape->mesh)
- delete shape->mesh;
+ RB_trimesh_data_delete(shape->mesh);
delete shape->cshape;
delete shape;
}
@@ -920,7 +975,7 @@ rbConstraint *RB_constraint_new_motor(float pivot[3], float orn[4], rbRigidBody
/* unlock motor axes */
con->getTranslationalLimitMotor()->m_upperLimit.setValue(-1.0f, -1.0f, -1.0f);
- return (rbConstraint*)con;
+ return (rbConstraint *)con;
}
/* Cleanup ----------------------------- */
diff --git a/release/scripts/addons b/release/scripts/addons
-Subproject c50944e808d6c74148237e85866e893628f0fee
+Subproject 92a03a1b94b4fae0b6c04d3c4fa2bdcd4df8a08
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
-Subproject 31545d25c9cb41d271a3f3ef84d327708572290
+Subproject 941d5d1857a13766fb39db1757659dc7a9e6127
diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py
index 870019acc96..977375fe38d 100644
--- a/release/scripts/startup/bl_operators/object.py
+++ b/release/scripts/startup/bl_operators/object.py
@@ -851,7 +851,7 @@ class LodClearAll(Operator):
class LodGenerate(Operator):
- """Generates levels of detail using the decimate modifier"""
+ """Generate levels of detail using the decimate modifier"""
bl_idname = "object.lod_generate"
bl_label = "Generate Levels of Detail"
bl_options = {'REGISTER', 'UNDO'}
diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
index cd701178976..5f589c499d3 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
@@ -70,6 +70,12 @@ class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
layout.prop(rbo, "collision_shape", text="Shape")
+ if rbo.collision_shape in {'MESH', 'CONVEX_HULL'}:
+ layout.prop(rbo, "mesh_source", text="Source")
+
+ if rbo.collision_shape == 'MESH' and rbo.mesh_source == 'DEFORM':
+ layout.prop(rbo, "use_deform", text="Deforming")
+
split = layout.split()
col = split.column()
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index d6a63c6497b..3a203c77463 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -98,7 +98,8 @@ class CLIP_HT_header(Header):
sub.active = clip.tracking.reconstruction.is_valid
sub.prop(sc, "show_graph_frames", icon='SEQUENCE', text="")
- row.prop(sc, "show_graph_tracks", icon='ANIM', text="")
+ row.prop(sc, "show_graph_tracks_motion", icon='IPO', text="")
+ row.prop(sc, "show_graph_tracks_error", icon='ANIM', text="")
else:
row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT',
text="Filters")
diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index 9da525d8ebb..989b0a0b6e3 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -161,8 +161,18 @@ class INFO_MT_file_external_data(Menu):
def draw(self, context):
layout = self.layout
- layout.operator("file.pack_all", text="Pack into .blend file")
- layout.operator("file.unpack_all", text="Unpack into Files")
+ icon = 'CHECKBOX_HLT' if bpy.data.use_autopack else 'CHECKBOX_DEHLT'
+ layout.operator("file.autopack_toggle", icon=icon)
+
+ layout.separator()
+
+ pack_all = layout.row()
+ pack_all.operator("file.pack_all")
+ pack_all.active = not bpy.data.use_autopack
+
+ unpack_all = layout.row()
+ unpack_all.operator("file.unpack_all")
+ unpack_all.active = not bpy.data.use_autopack
layout.separator()
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index f5f6cab60a2..b4550584b4d 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -651,7 +651,7 @@ DerivedMesh *getEditDerivedBMesh(struct BMEditMesh *em, struct Object *ob,
DerivedMesh *mesh_create_derived_index_render(struct Scene *scene, struct Object *ob, CustomDataMask dataMask, int index);
/* same as above but wont use render settings */
-DerivedMesh *mesh_create_derived(struct Mesh *me, struct Object *ob, float (*vertCos)[3]);
+DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]);
DerivedMesh *mesh_create_derived_view(struct Scene *scene, struct Object *ob,
CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_no_deform(struct Scene *scene, struct Object *ob,
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 3ac5c8c9a76..9068be970b5 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -134,13 +134,16 @@ void action_groups_clear_tempflags(struct bAction *act);
/* Pose API ----------------- */
void BKE_pose_channel_free(struct bPoseChannel *pchan);
+void BKE_pose_channel_free_ex(struct bPoseChannel *pchan, bool do_id_user);
void BKE_pose_channels_free(struct bPose *pose);
+void BKE_pose_channels_free_ex(struct bPose *pose, bool do_id_user);
void BKE_pose_channels_hash_make(struct bPose *pose);
void BKE_pose_channels_hash_free(struct bPose *pose);
void BKE_pose_free(struct bPose *pose);
+void BKE_pose_free_ex(struct bPose *pose, bool do_id_user);
void BKE_pose_copy_data(struct bPose **dst, struct bPose *src, const bool copy_constraints);
void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from);
struct bPoseChannel *BKE_pose_channel_find_name(const struct bPose *pose, const char *name);
diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h
index 560617db474..7006b2904ac 100644
--- a/source/blender/blenkernel/BKE_cdderivedmesh.h
+++ b/source/blender/blenkernel/BKE_cdderivedmesh.h
@@ -53,7 +53,7 @@ int CDDM_Check(struct DerivedMesh *dm);
* original data in Mesh, but it is safe to apply vertex coordinates or
* calculate normals as those functions will automatically create new
* data to not overwrite the original */
-struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh, struct Object *ob);
+struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh);
struct DerivedMesh *CDDM_from_bmesh(struct BMesh *bm, int use_mdisps);
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index bdfa0973838..cad3f264fb8 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -74,6 +74,7 @@ struct ListBase *which_libbase(struct Main *mainlib, short type);
int set_listbasepointers(struct Main *main, struct ListBase **lb);
void BKE_libblock_free(struct ListBase *lb, void *idv);
+void BKE_libblock_free_ex(struct ListBase *lb, void *idv, bool do_id_user);
void BKE_libblock_free_us(struct ListBase *lb, void *idv);
void BKE_libblock_free_data(struct ID *id);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index b5e75729659..6ed8406d9a4 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -66,6 +66,7 @@ void BKE_object_free_curve_cache(struct Object *ob);
void BKE_object_update_base_layer(struct Scene *scene, struct Object *ob);
void BKE_object_free(struct Object *ob);
+void BKE_object_free_ex(struct Object *ob, bool do_id_user);
void BKE_object_free_derived_caches(struct Object *ob);
void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData *hmd);
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index 34ed4f2c8b1..86be3bfe770 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -67,10 +67,7 @@ struct RigidBodyWorld *BKE_rigidbody_world_copy(struct RigidBodyWorld *rbw);
void BKE_rigidbody_world_groups_relink(struct RigidBodyWorld *rbw);
/* 'validate' (i.e. make new or replace old) Physics-Engine objects */
-void BKE_rigidbody_validate_sim_world(struct Scene *scene, struct RigidBodyWorld *rbw, short rebuild);
-void BKE_rigidbody_validate_sim_object(struct RigidBodyWorld *rbw, struct Object *ob, short rebuild);
-void BKE_rigidbody_validate_sim_shape(struct Object *ob, short rebuild);
-void BKE_rigidbody_validate_sim_constraint(struct RigidBodyWorld *rbw, struct Object *ob, short rebuild);
+void BKE_rigidbody_validate_sim_world(struct Scene *scene, struct RigidBodyWorld *rbw, bool rebuild);
/* -------------- */
/* Utilities */
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index fa0f6e3af28..b48b7629d41 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -838,9 +838,9 @@ void DM_interp_poly_data(DerivedMesh *source, DerivedMesh *dest,
}
///
-DerivedMesh *mesh_create_derived(Mesh *me, Object *ob, float (*vertCos)[3])
+DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
{
- DerivedMesh *dm = CDDM_from_mesh(me, ob);
+ DerivedMesh *dm = CDDM_from_mesh(me);
if (!dm)
return NULL;
@@ -874,7 +874,7 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob,
float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
modwrap_deformVerts(md, ob, NULL, deformedVerts, numVerts, 0);
- dm = mesh_create_derived(me, ob, deformedVerts);
+ dm = mesh_create_derived(me, deformedVerts);
if (build_shapekey_layers)
add_shapekey_layers(dm, me, ob);
@@ -882,7 +882,7 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob,
MEM_freeN(deformedVerts);
}
else {
- DerivedMesh *tdm = mesh_create_derived(me, ob, NULL);
+ DerivedMesh *tdm = mesh_create_derived(me, NULL);
if (build_shapekey_layers)
add_shapekey_layers(tdm, me, ob);
@@ -953,7 +953,7 @@ static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, BMEditMesh *em, int lay
int free;
if (em) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
- else dm = CDDM_from_mesh(me, ob);
+ else dm = CDDM_from_mesh(me);
orco = get_orco_coords_dm(ob, em, layer, &free);
@@ -1533,7 +1533,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
* coordinates (vpaint, etc.)
*/
if (deform_r) {
- *deform_r = CDDM_from_mesh(me, ob);
+ *deform_r = CDDM_from_mesh(me);
if (build_shapekey_layers)
add_shapekey_layers(dm, me, ob);
@@ -1659,7 +1659,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
}
}
else {
- dm = CDDM_from_mesh(me, ob);
+ dm = CDDM_from_mesh(me);
ASSERT_IS_VALID_DM(dm);
if (build_shapekey_layers)
@@ -1823,7 +1823,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
#endif
}
else {
- finaldm = CDDM_from_mesh(me, ob);
+ finaldm = CDDM_from_mesh(me);
if (build_shapekey_layers) {
add_shapekey_layers(finaldm, me, ob);
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index c91fae2adbc..4991f1ce225 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -714,10 +714,12 @@ void BKE_pose_channels_hash_free(bPose *pose)
* Deallocates a pose channel.
* Does not free the pose channel itself.
*/
-void BKE_pose_channel_free(bPoseChannel *pchan)
+void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user)
{
if (pchan->custom) {
- id_us_min(&pchan->custom->id);
+ if (do_id_user) {
+ id_us_min(&pchan->custom->id);
+ }
pchan->custom = NULL;
}
@@ -734,17 +736,22 @@ void BKE_pose_channel_free(bPoseChannel *pchan)
}
}
+void BKE_pose_channel_free(bPoseChannel *pchan)
+{
+ BKE_pose_channel_free_ex(pchan, true);
+}
+
/**
* Removes and deallocates all channels from a pose.
* Does not free the pose itself.
*/
-void BKE_pose_channels_free(bPose *pose)
+void BKE_pose_channels_free_ex(bPose *pose, bool do_id_user)
{
bPoseChannel *pchan;
if (pose->chanbase.first) {
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next)
- BKE_pose_channel_free(pchan);
+ BKE_pose_channel_free_ex(pchan, do_id_user);
BLI_freelistN(&pose->chanbase);
}
@@ -752,14 +759,19 @@ void BKE_pose_channels_free(bPose *pose)
BKE_pose_channels_hash_free(pose);
}
+void BKE_pose_channels_free(bPose *pose)
+{
+ BKE_pose_channels_free_ex(pose, true);
+}
+
/**
* Removes and deallocates all data from a pose, and also frees the pose.
*/
-void BKE_pose_free(bPose *pose)
+void BKE_pose_free_ex(bPose *pose, bool do_id_user)
{
if (pose) {
/* free pose-channels */
- BKE_pose_channels_free(pose);
+ BKE_pose_channels_free_ex(pose, do_id_user);
/* free pose-groups */
if (pose->agroups.first)
@@ -777,6 +789,11 @@ void BKE_pose_free(bPose *pose)
}
}
+void BKE_pose_free(bPose *pose)
+{
+ BKE_pose_free_ex(pose, true);
+}
+
static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan)
{
bConstraint *pcon, *con;
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index d9447e51aa3..32914dedde1 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -1802,9 +1802,9 @@ DerivedMesh *CDDM_new(int numVerts, int numEdges, int numTessFaces, int numLoops
return dm;
}
-DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob))
+DerivedMesh *CDDM_from_mesh(Mesh *mesh)
{
- CDDerivedMesh *cddm = cdDM_create("CDDM_from_mesh dm");
+ CDDerivedMesh *cddm = cdDM_create(__func__);
DerivedMesh *dm = &cddm->dm;
CustomDataMask mask = CD_MASK_MESH & (~CD_MASK_MDISPS);
int alloctype;
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 8074d6bceec..6376878c664 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -2735,7 +2735,7 @@ void DAG_threaded_update_begin(Scene *scene,
void (*func)(void *node, void *user_data),
void *user_data)
{
- DagNode *node, *root_node;
+ DagNode *node;
/* We reset num_pending_parents to zero first and tag node as not scheduled yet... */
for (node = scene->theDag->DagNode.first; node; node = node->next) {
@@ -2756,10 +2756,15 @@ void DAG_threaded_update_begin(Scene *scene,
}
}
- /* Add root node to the queue. */
- root_node = scene->theDag->DagNode.first;
- root_node->scheduled = true;
- func(root_node, user_data);
+ /* Add root nodes to the queue. */
+ BLI_spin_lock(&threaded_update_lock);
+ for (node = scene->theDag->DagNode.first; node; node = node->next) {
+ if (node->num_pending_parents == 0) {
+ node->scheduled = true;
+ func(node, user_data);
+ }
+ }
+ BLI_spin_unlock(&threaded_update_lock);
}
/* This function is called when handling node is done.
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 00dee2611c1..43bd6a0b36c 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -868,7 +868,7 @@ void BKE_libblock_free_data(ID *id)
}
/* used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c */
-void BKE_libblock_free(ListBase *lb, void *idv)
+void BKE_libblock_free_ex(ListBase *lb, void *idv, bool do_id_user)
{
Main *bmain = G.main; /* should eventually be an arg */
ID *id = idv;
@@ -885,7 +885,7 @@ void BKE_libblock_free(ListBase *lb, void *idv)
BKE_library_free((Library *)id);
break;
case ID_OB:
- BKE_object_free((Object *)id);
+ BKE_object_free_ex((Object *)id, do_id_user);
break;
case ID_ME:
BKE_mesh_free((Mesh *)id, 1);
@@ -951,7 +951,7 @@ void BKE_libblock_free(ListBase *lb, void *idv)
BKE_action_free((bAction *)id);
break;
case ID_NT:
- ntreeFreeTree((bNodeTree *)id);
+ ntreeFreeTree_ex((bNodeTree *)id, do_id_user);
break;
case ID_BR:
BKE_brush_free((Brush *)id);
@@ -988,6 +988,11 @@ void BKE_libblock_free(ListBase *lb, void *idv)
MEM_freeN(id);
}
+void BKE_libblock_free(ListBase *lb, void *idv)
+{
+ BKE_libblock_free_ex(lb, idv, true);
+}
+
void BKE_libblock_free_us(ListBase *lb, void *idv) /* test users */
{
ID *id = idv;
@@ -1025,44 +1030,44 @@ void free_main(Main *mainvar)
while ( (id = lb->first) ) {
#if 1
- BKE_libblock_free(lb, id);
+ BKE_libblock_free_ex(lb, id, false);
#else
/* errors freeing ID's can be hard to track down,
* enable this so valgrind will give the line number in its error log */
switch (a) {
- case 0: BKE_libblock_free(lb, id); break;
- case 1: BKE_libblock_free(lb, id); break;
- case 2: BKE_libblock_free(lb, id); break;
- case 3: BKE_libblock_free(lb, id); break;
- case 4: BKE_libblock_free(lb, id); break;
- case 5: BKE_libblock_free(lb, id); break;
- case 6: BKE_libblock_free(lb, id); break;
- case 7: BKE_libblock_free(lb, id); break;
- case 8: BKE_libblock_free(lb, id); break;
- case 9: BKE_libblock_free(lb, id); break;
- case 10: BKE_libblock_free(lb, id); break;
- case 11: BKE_libblock_free(lb, id); break;
- case 12: BKE_libblock_free(lb, id); break;
- case 13: BKE_libblock_free(lb, id); break;
- case 14: BKE_libblock_free(lb, id); break;
- case 15: BKE_libblock_free(lb, id); break;
- case 16: BKE_libblock_free(lb, id); break;
- case 17: BKE_libblock_free(lb, id); break;
- case 18: BKE_libblock_free(lb, id); break;
- case 19: BKE_libblock_free(lb, id); break;
- case 20: BKE_libblock_free(lb, id); break;
- case 21: BKE_libblock_free(lb, id); break;
- case 22: BKE_libblock_free(lb, id); break;
- case 23: BKE_libblock_free(lb, id); break;
- case 24: BKE_libblock_free(lb, id); break;
- case 25: BKE_libblock_free(lb, id); break;
- case 26: BKE_libblock_free(lb, id); break;
- case 27: BKE_libblock_free(lb, id); break;
- case 28: BKE_libblock_free(lb, id); break;
- case 29: BKE_libblock_free(lb, id); break;
- case 30: BKE_libblock_free(lb, id); break;
- case 31: BKE_libblock_free(lb, id); break;
- case 32: BKE_libblock_free(lb, id); break;
+ case 0: BKE_libblock_free_ex(lb, id, false); break;
+ case 1: BKE_libblock_free_ex(lb, id, false); break;
+ case 2: BKE_libblock_free_ex(lb, id, false); break;
+ case 3: BKE_libblock_free_ex(lb, id, false); break;
+ case 4: BKE_libblock_free_ex(lb, id, false); break;
+ case 5: BKE_libblock_free_ex(lb, id, false); break;
+ case 6: BKE_libblock_free_ex(lb, id, false); break;
+ case 7: BKE_libblock_free_ex(lb, id, false); break;
+ case 8: BKE_libblock_free_ex(lb, id, false); break;
+ case 9: BKE_libblock_free_ex(lb, id, false); break;
+ case 10: BKE_libblock_free_ex(lb, id, false); break;
+ case 11: BKE_libblock_free_ex(lb, id, false); break;
+ case 12: BKE_libblock_free_ex(lb, id, false); break;
+ case 13: BKE_libblock_free_ex(lb, id, false); break;
+ case 14: BKE_libblock_free_ex(lb, id, false); break;
+ case 15: BKE_libblock_free_ex(lb, id, false); break;
+ case 16: BKE_libblock_free_ex(lb, id, false); break;
+ case 17: BKE_libblock_free_ex(lb, id, false); break;
+ case 18: BKE_libblock_free_ex(lb, id, false); break;
+ case 19: BKE_libblock_free_ex(lb, id, false); break;
+ case 20: BKE_libblock_free_ex(lb, id, false); break;
+ case 21: BKE_libblock_free_ex(lb, id, false); break;
+ case 22: BKE_libblock_free_ex(lb, id, false); break;
+ case 23: BKE_libblock_free_ex(lb, id, false); break;
+ case 24: BKE_libblock_free_ex(lb, id, false); break;
+ case 25: BKE_libblock_free_ex(lb, id, false); break;
+ case 26: BKE_libblock_free_ex(lb, id, false); break;
+ case 27: BKE_libblock_free_ex(lb, id, false); break;
+ case 28: BKE_libblock_free_ex(lb, id, false); break;
+ case 29: BKE_libblock_free_ex(lb, id, false); break;
+ case 30: BKE_libblock_free_ex(lb, id, false); break;
+ case 31: BKE_libblock_free_ex(lb, id, false); break;
+ case 32: BKE_libblock_free_ex(lb, id, false); break;
default:
BLI_assert(0);
break;
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 722ea536ed2..2189fbd2f55 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -769,7 +769,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
/* XXX - probably not necessary to regenerate the cddm so much? */
/* generate highest level with displacements */
- cddm = CDDM_from_mesh(me, NULL);
+ cddm = CDDM_from_mesh(me);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
dispdm = multires_dm_create_local(ob, cddm, totlvl, totlvl, 0, 0);
cddm->release(cddm);
@@ -782,7 +782,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
/* heuristic to produce a better-fitting base mesh */
- cddm = CDDM_from_mesh(me, NULL);
+ cddm = CDDM_from_mesh(me);
pmap = cddm->getPolyMap(ob, cddm);
origco = MEM_callocN(sizeof(float) * 3 * me->totvert, "multires apply base origco");
for (i = 0; i < me->totvert; ++i)
@@ -865,7 +865,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
BKE_mesh_calc_normals(me);
/* subdivide the mesh to highest level without displacements */
- cddm = CDDM_from_mesh(me, NULL);
+ cddm = CDDM_from_mesh(me);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
origdm = subsurf_dm_create_local(ob, cddm, totlvl, 0, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0);
cddm->release(cddm);
@@ -902,7 +902,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
int has_mask = CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK);
/* create subsurf DM from original mesh at high level */
- cddm = CDDM_from_mesh(me, NULL);
+ cddm = CDDM_from_mesh(me);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask);
ss = ((CCGDerivedMesh *)highdm)->ss;
@@ -1174,7 +1174,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
/* create subsurf DM from original mesh at high level */
if (ob->derivedDeform) cddm = CDDM_copy(ob->derivedDeform);
- else cddm = CDDM_from_mesh(me, NULL);
+ else cddm = CDDM_from_mesh(me);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask);
@@ -1236,7 +1236,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
int has_mask = CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK);
if (ob->derivedDeform) cddm = CDDM_copy(ob->derivedDeform);
- else cddm = CDDM_from_mesh(me, NULL);
+ else cddm = CDDM_from_mesh(me);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask);
@@ -2114,7 +2114,7 @@ void multires_load_old(Object *ob, Mesh *me)
multiresModifier_subdivide(mmd, ob, 1, 0);
mmd->lvl = mmd->totlvl;
- orig = CDDM_from_mesh(me, NULL);
+ orig = CDDM_from_mesh(me);
/* XXX We *must* alloc paint mask here, else we have some kind of mismatch in
* multires_modifier_update_mdisps() (called by dm->release(dm)), which always creates the
* reference subsurfed dm with this option, before calling multiresModifier_disp_run(),
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index d0ce56332a7..977aa016d2e 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1714,8 +1714,11 @@ void ntreeFreeTree_ex(bNodeTree *ntree, const short do_id_user)
}
}
- /* XXX not nice, but needed to free localized node groups properly */
- free_localized_node_groups(ntree);
+ /* when freeing main, this would check other ntree's which may have been freed, see [#37939] */
+ if (do_id_user) {
+ /* XXX not nice, but needed to free localized node groups properly */
+ free_localized_node_groups(ntree);
+ }
/* unregister associated RNA types */
ntreeInterfaceTypeFree(ntree);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 26684d19507..711065b0e8b 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -321,7 +321,7 @@ void BKE_object_free_derived_caches(Object *ob)
}
/* do not free object itself */
-void BKE_object_free(Object *ob)
+void BKE_object_free_ex(Object *ob, bool do_id_user)
{
int a;
@@ -364,7 +364,7 @@ void BKE_object_free(Object *ob)
if (ob->defbase.first)
BLI_freelistN(&ob->defbase);
if (ob->pose)
- BKE_pose_free(ob->pose);
+ BKE_pose_free_ex(ob->pose, do_id_user);
if (ob->mpath)
animviz_free_motionpath(ob->mpath);
BKE_bproperty_free_list(&ob->prop);
@@ -399,6 +399,11 @@ void BKE_object_free(Object *ob)
}
}
+void BKE_object_free(Object *ob)
+{
+ BKE_object_free_ex(ob, true);
+}
+
static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Object **obpoin)
{
Object *unlinkOb = userData;
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 0f5707f9a60..37ca502970d 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -1106,7 +1106,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
/* Grid distribution */
if (part->distr==PART_DISTR_GRID && from != PART_FROM_VERT) {
BLI_srandom(31415926 + psys->seed);
- dm= CDDM_from_mesh((Mesh*)ob->data, ob);
+ dm= CDDM_from_mesh((Mesh*)ob->data);
DM_ensure_tessface(dm);
distribute_grid(dm,psys);
dm->release(dm);
@@ -1145,7 +1145,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
if (psys->part->use_modifier_stack)
dm = finaldm;
else
- dm= CDDM_from_mesh((Mesh*)ob->data, ob);
+ dm= CDDM_from_mesh((Mesh*)ob->data);
/* BMESH ONLY, for verts we don't care about tessfaces */
if (from != PART_FROM_VERT) {
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 600805e71ce..271a9a91f95 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -225,26 +225,47 @@ void BKE_rigidbody_relink_constraint(RigidBodyCon *rbc)
/* ************************************** */
/* Setup Utilities - Validate Sim Instances */
+/* get the appropriate DerivedMesh based on rigid body mesh source */
+static DerivedMesh *rigidbody_get_mesh(Object *ob)
+{
+ if (ob->rigidbody_object->mesh_source == RBO_MESH_DEFORM) {
+ return ob->derivedDeform;
+ }
+ else if (ob->rigidbody_object->mesh_source == RBO_MESH_FINAL) {
+ return ob->derivedFinal;
+ }
+ else {
+ return CDDM_from_mesh(ob->data);
+ }
+}
+
/* create collision shape of mesh - convex hull */
static rbCollisionShape *rigidbody_get_shape_convexhull_from_mesh(Object *ob, float margin, bool *can_embed)
{
rbCollisionShape *shape = NULL;
- Mesh *me = NULL;
+ DerivedMesh *dm = NULL;
+ MVert *mvert = NULL;
+ int totvert = 0;
if (ob->type == OB_MESH && ob->data) {
- me = ob->data;
+ dm = rigidbody_get_mesh(ob);
+ mvert = (dm) ? dm->getVertArray(dm) : NULL;
+ totvert = (dm) ? dm->getNumVerts(dm) : 0;
}
else {
printf("ERROR: cannot make Convex Hull collision shape for non-Mesh object\n");
}
- if (me && me->totvert) {
- shape = RB_shape_new_convex_hull((float *)me->mvert, sizeof(MVert), me->totvert, margin, can_embed);
+ if (totvert) {
+ shape = RB_shape_new_convex_hull((float *)mvert, sizeof(MVert), totvert, margin, can_embed);
}
else {
printf("ERROR: no vertices to define Convex Hull collision shape with\n");
}
+ if (dm && ob->rigidbody_object->mesh_source == RBO_MESH_BASE)
+ dm->release(dm);
+
return shape;
}
@@ -256,14 +277,20 @@ static rbCollisionShape *rigidbody_get_shape_trimesh_from_mesh(Object *ob)
rbCollisionShape *shape = NULL;
if (ob->type == OB_MESH) {
- DerivedMesh *dm = CDDM_from_mesh(ob->data, ob);
-
+ DerivedMesh *dm = NULL;
MVert *mvert;
MFace *mface;
int totvert;
int totface;
+ int tottris = 0;
+ int triangle_index = 0;
+
+ dm = rigidbody_get_mesh(ob);
/* ensure mesh validity, then grab data */
+ if (dm == NULL)
+ return NULL;
+
DM_ensure_tessface(dm);
mvert = (dm) ? dm->getVertArray(dm) : NULL;
@@ -278,32 +305,32 @@ static rbCollisionShape *rigidbody_get_shape_trimesh_from_mesh(Object *ob)
else {
rbMeshData *mdata;
int i;
+
+ /* count triangles */
+ for (i = 0; i < totface; i++) {
+ (mface[i].v4) ? (tottris += 2) : (tottris += 1);
+ }
/* init mesh data for collision shape */
- mdata = RB_trimesh_data_new();
+ mdata = RB_trimesh_data_new(tottris, totvert);
+
+ RB_trimesh_add_vertices(mdata, (float*)mvert, totvert, sizeof(MVert));
/* loop over all faces, adding them as triangles to the collision shape
* (so for some faces, more than triangle will get added)
*/
for (i = 0; (i < totface) && (mface) && (mvert); i++, mface++) {
/* add first triangle - verts 1,2,3 */
- {
- MVert *va = (mface->v1 < totvert) ? (mvert + mface->v1) : (mvert);
- MVert *vb = (mface->v2 < totvert) ? (mvert + mface->v2) : (mvert);
- MVert *vc = (mface->v3 < totvert) ? (mvert + mface->v3) : (mvert);
-
- RB_trimesh_add_triangle(mdata, va->co, vb->co, vc->co);
- }
+ RB_trimesh_add_triangle_indices(mdata, triangle_index, mface->v1, mface->v2, mface->v3);
+ triangle_index++;
/* add second triangle if needed - verts 1,3,4 */
if (mface->v4) {
- MVert *va = (mface->v1 < totvert) ? (mvert + mface->v1) : (mvert);
- MVert *vb = (mface->v3 < totvert) ? (mvert + mface->v3) : (mvert);
- MVert *vc = (mface->v4 < totvert) ? (mvert + mface->v4) : (mvert);
-
- RB_trimesh_add_triangle(mdata, va->co, vb->co, vc->co);
+ RB_trimesh_add_triangle_indices(mdata, triangle_index, mface->v1, mface->v3, mface->v4);
+ triangle_index++;
}
}
+ RB_trimesh_finish(mdata);
/* construct collision shape
*
@@ -323,7 +350,7 @@ static rbCollisionShape *rigidbody_get_shape_trimesh_from_mesh(Object *ob)
}
/* cleanup temp data */
- if (dm) {
+ if (dm && ob->rigidbody_object->mesh_source == RBO_MESH_BASE) {
dm->release(dm);
}
}
@@ -337,7 +364,7 @@ static rbCollisionShape *rigidbody_get_shape_trimesh_from_mesh(Object *ob)
/* Create new physics sim collision shape for object and store it,
* or remove the existing one first and replace...
*/
-void BKE_rigidbody_validate_sim_shape(Object *ob, short rebuild)
+static void rigidbody_validate_sim_shape(Object *ob, bool rebuild)
{
RigidBodyOb *rbo = ob->rigidbody_object;
rbCollisionShape *new_shape = NULL;
@@ -425,9 +452,10 @@ void BKE_rigidbody_validate_sim_shape(Object *ob, short rebuild)
rbo->physics_shape = new_shape;
RB_shape_set_margin(rbo->physics_shape, RBO_GET_MARGIN(rbo));
}
- else { /* otherwise fall back to box shape */
+ /* use box shape if we can't fall back to old shape */
+ else if (rbo->physics_shape == NULL) {
rbo->shape = RB_SHAPE_BOX;
- BKE_rigidbody_validate_sim_shape(ob, true);
+ rigidbody_validate_sim_shape(ob, true);
}
}
@@ -436,7 +464,7 @@ void BKE_rigidbody_validate_sim_shape(Object *ob, short rebuild)
/* Create physics sim representation of object given RigidBody settings
* < rebuild: even if an instance already exists, replace it
*/
-void BKE_rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, short rebuild)
+static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool rebuild)
{
RigidBodyOb *rbo = (ob) ? ob->rigidbody_object : NULL;
float loc[3];
@@ -451,10 +479,9 @@ void BKE_rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, short re
/* make sure collision shape exists */
/* FIXME we shouldn't always have to rebuild collision shapes when rebuilding objects, but it's needed for constraints to update correctly */
if (rbo->physics_shape == NULL || rebuild)
- BKE_rigidbody_validate_sim_shape(ob, true);
+ rigidbody_validate_sim_shape(ob, true);
- if (rbo->physics_object) {
- if (rebuild == false)
+ if (rbo->physics_object && rebuild == false) {
RB_dworld_remove_body(rbw->physics_world, rbo->physics_object);
}
if (!rbo->physics_object || rebuild) {
@@ -500,7 +527,7 @@ void BKE_rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, short re
/* Create physics sim representation of constraint given rigid body constraint settings
* < rebuild: even if an instance already exists, replace it
*/
-void BKE_rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, short rebuild)
+static void rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, bool rebuild)
{
RigidBodyCon *rbc = (ob) ? ob->rigidbody_constraint : NULL;
float loc[3];
@@ -527,8 +554,7 @@ void BKE_rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, shor
return;
}
- if (rbc->physics_constraint) {
- if (rebuild == false)
+ if (rbc->physics_constraint && rebuild == false) {
RB_dworld_remove_constraint(rbw->physics_world, rbc->physics_constraint);
}
if (rbc->physics_constraint == NULL || rebuild) {
@@ -672,7 +698,7 @@ void BKE_rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, shor
/* Create physics sim world given RigidBody world settings */
// NOTE: this does NOT update object references that the scene uses, in case those aren't ready yet!
-void BKE_rigidbody_validate_sim_world(Scene *scene, RigidBodyWorld *rbw, short rebuild)
+void BKE_rigidbody_validate_sim_world(Scene *scene, RigidBodyWorld *rbw, bool rebuild)
{
/* sanity checks */
if (rbw == NULL)
@@ -798,6 +824,8 @@ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type)
else
rbo->shape = RB_SHAPE_TRIMESH;
+ rbo->mesh_source = RBO_MESH_DEFORM;
+
/* set initial transform */
mat4_to_loc_quat(rbo->pos, rbo->orn, ob->obmat);
@@ -1000,6 +1028,17 @@ static void rigidbody_update_sim_ob(Scene *scene, RigidBodyWorld *rbw, Object *o
if (rbo->physics_object == NULL)
return;
+ if (rbo->shape == RB_SHAPE_TRIMESH && rbo->flag & RBO_FLAG_USE_DEFORM) {
+ DerivedMesh *dm = ob->derivedDeform;
+ if (dm) {
+ MVert *mvert = dm->getVertArray(dm);
+ int totvert = dm->getNumVerts(dm);
+ BoundBox *bb = BKE_object_boundbox_get(ob);
+
+ RB_shape_trimesh_update(rbo->physics_shape, (float*)mvert, totvert, sizeof(MVert), bb->vec[0], bb->vec[6]);
+ }
+ }
+
mat4_decompose(loc, rot, scale, ob->obmat);
/* update scale for all objects */
@@ -1091,7 +1130,7 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, int r
* - assume object to be active? That is the default for newly added settings...
*/
ob->rigidbody_object = BKE_rigidbody_create_object(scene, ob, RBO_TYPE_ACTIVE);
- BKE_rigidbody_validate_sim_object(rbw, ob, true);
+ rigidbody_validate_sim_object(rbw, ob, true);
rbo = ob->rigidbody_object;
}
@@ -1100,15 +1139,15 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, int r
/* refresh object... */
if (rebuild) {
/* World has been rebuilt so rebuild object */
- BKE_rigidbody_validate_sim_object(rbw, ob, true);
+ rigidbody_validate_sim_object(rbw, ob, true);
}
else if (rbo->flag & RBO_FLAG_NEEDS_VALIDATE) {
- BKE_rigidbody_validate_sim_object(rbw, ob, false);
+ rigidbody_validate_sim_object(rbw, ob, false);
}
/* refresh shape... */
if (rbo->flag & RBO_FLAG_NEEDS_RESHAPE) {
/* mesh/shape data changed, so force shape refresh */
- BKE_rigidbody_validate_sim_shape(ob, true);
+ rigidbody_validate_sim_shape(ob, true);
/* now tell RB sim about it */
// XXX: we assume that this can only get applied for active/passive shapes that will be included as rigidbodies
RB_body_set_collision_shape(rbo->physics_object, rbo->physics_shape);
@@ -1137,7 +1176,7 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, int r
* constraint settings (perhaps it was added manually), add!
*/
ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, RBC_TYPE_FIXED);
- BKE_rigidbody_validate_sim_constraint(rbw, ob, true);
+ rigidbody_validate_sim_constraint(rbw, ob, true);
rbc = ob->rigidbody_constraint;
}
@@ -1145,10 +1184,10 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, int r
/* perform simulation data updates as tagged */
if (rebuild) {
/* World has been rebuilt so rebuild constraint */
- BKE_rigidbody_validate_sim_constraint(rbw, ob, true);
+ rigidbody_validate_sim_constraint(rbw, ob, true);
}
else if (rbc->flag & RBC_FLAG_NEEDS_VALIDATE) {
- BKE_rigidbody_validate_sim_constraint(rbw, ob, false);
+ rigidbody_validate_sim_constraint(rbw, ob, false);
}
rbc->flag &= ~RBC_FLAG_NEEDS_VALIDATE;
}
@@ -1355,10 +1394,7 @@ void BKE_rigidbody_free_constraint(Object *ob) {}
struct RigidBodyOb *BKE_rigidbody_copy_object(Object *ob) { return NULL; }
struct RigidBodyCon *BKE_rigidbody_copy_constraint(Object *ob) { return NULL; }
void BKE_rigidbody_relink_constraint(RigidBodyCon *rbc) {}
-void BKE_rigidbody_validate_sim_shape(Object *ob, short rebuild) {}
-void BKE_rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, short rebuild) {}
-void BKE_rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, short rebuild) {}
-void BKE_rigidbody_validate_sim_world(Scene *scene, RigidBodyWorld *rbw, short rebuild) {}
+void BKE_rigidbody_validate_sim_world(Scene *scene, RigidBodyWorld *rbw, bool rebuild) {}
struct RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene) { return NULL; }
struct RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw) { return NULL; }
void BKE_rigidbody_world_groups_relink(struct RigidBodyWorld *rbw) {}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 84b9b0aadf4..3ca702e0068 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1293,7 +1293,7 @@ static void scene_update_object_func(TaskPool *pool, void *taskdata, int threadi
}
/* Update will decrease child's valency and schedule child with zero valency. */
- DAG_threaded_update_handle_node_updated(node,scene_update_object_add_task, pool);
+ DAG_threaded_update_handle_node_updated(node, scene_update_object_add_task, pool);
#undef PRINT
}
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index e94db6f637c..188c80e7cc8 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -3693,7 +3693,7 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])
CCGSubSurf *ss = _getSubSurf(NULL, 1, 3, CCG_USE_ARENA);
float edge_sum[3], face_sum[3];
CCGVertIterator *vi;
- DerivedMesh *dm = CDDM_from_mesh(me, NULL);
+ DerivedMesh *dm = CDDM_from_mesh(me);
ss_sync_from_derivedmesh(ss, dm, NULL, 0);
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 11875722d27..1d03bf42f83 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -721,24 +721,16 @@ bool isect_point_poly_v2(const float pt[2], const float verts[][2], const unsign
/* first vector */
fp1[0] = (float)(p1[0] - pt[0]);
fp1[1] = (float)(p1[1] - pt[1]);
- normalize_v2(fp1);
for (i = 0; i < nr; i++) {
- float dot, ang, cross;
p2 = verts[i];
/* second vector */
fp2[0] = (float)(p2[0] - pt[0]);
fp2[1] = (float)(p2[1] - pt[1]);
- normalize_v2(fp2);
/* dot and angle and cross */
- dot = dot_v2v2(fp1, fp2);
- ang = fabsf(saacos(dot));
- cross = (float)((p1[1] - p2[1]) * (p1[0] - pt[0]) + (p2[0] - p1[0]) * (p1[1] - pt[1]));
-
- if (cross < 0.0f) angletot -= ang;
- else angletot += ang;
+ angletot += angle_signed_v2v2(fp1, fp2);
/* circulate */
copy_v2_v2(fp1, fp2);
@@ -769,24 +761,16 @@ bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsign
/* first vector */
fp1[0] = (float)(p1[0] - pt[0]);
fp1[1] = (float)(p1[1] - pt[1]);
- normalize_v2(fp1);
for (i = 0; i < nr; i++) {
- float dot, ang, cross;
p2 = verts[i];
/* second vector */
fp2[0] = (float)(p2[0] - pt[0]);
fp2[1] = (float)(p2[1] - pt[1]);
- normalize_v2(fp2);
/* dot and angle and cross */
- dot = dot_v2v2(fp1, fp2);
- ang = fabsf(saacos(dot));
- cross = (float)((p1[1] - p2[1]) * (p1[0] - pt[0]) + (p2[0] - p1[0]) * (p1[1] - pt[1]));
-
- if (cross < 0.0f) angletot -= ang;
- else angletot += ang;
+ angletot += angle_signed_v2v2(fp1, fp2);
/* circulate */
copy_v2_v2(fp1, fp2);
diff --git a/source/blender/blenlib/intern/polyfill2d.c b/source/blender/blenlib/intern/polyfill2d.c
index 287a0909870..f5a226cebb6 100644
--- a/source/blender/blenlib/intern/polyfill2d.c
+++ b/source/blender/blenlib/intern/polyfill2d.c
@@ -50,8 +50,6 @@
#include "BLI_strict_flags.h"
-#define SIGN_EPS 0.000001f
-
/* avoid fan-fill topology */
#define USE_CLIP_EVEN
#define USE_CONVEX_SKIP
@@ -97,7 +95,7 @@ static void pf_ear_tip_cut(PolyFill *pf, unsigned int index_ear_tip);
BLI_INLINE eSign signum_i(float a)
{
- if (UNLIKELY(fabsf(a) < SIGN_EPS))
+ if (UNLIKELY(a == 0.0f))
return 0;
else if (a > 0.0f)
return 1;
@@ -105,9 +103,23 @@ BLI_INLINE eSign signum_i(float a)
return -1;
}
+/**
+ * alternative version of #area_tri_signed_v2
+ * needed because of float precision issues
+ *
+ * \note removes / 2 since its not needed since we only need ths sign.
+ */
+BLI_INLINE float area_tri_signed_v2_alt_2x(const float v1[2], const float v2[2], const float v3[2])
+{
+ return ((v1[0] * (v2[1] - v3[1])) +
+ (v2[0] * (v3[1] - v1[1])) +
+ (v3[0] * (v1[1] - v2[1])));
+}
+
+
static eSign span_tri_v2_sign(const float v1[2], const float v2[2], const float v3[2])
{
- return signum_i(area_tri_signed_v2(v3, v2, v1));
+ return signum_i(area_tri_signed_v2_alt_2x(v3, v2, v1));
}
static unsigned int *pf_tri_add(PolyFill *pf)
@@ -316,9 +328,9 @@ static bool pf_ear_tip_check(PolyFill *pf, const unsigned int index_ear_tip)
/* Because the polygon has clockwise winding order,
* the area sign will be positive if the point is strictly inside.
* It will be 0 on the edge, which we want to include as well. */
- if ((span_tri_v2_sign(v1, v2, v) == CONVEX) &&
- (span_tri_v2_sign(v2, v3, v) == CONVEX) &&
- (span_tri_v2_sign(v3, v1, v) == CONVEX))
+ if ((span_tri_v2_sign(v1, v2, v) != CONCAVE) &&
+ (span_tri_v2_sign(v2, v3, v) != CONCAVE) &&
+ (span_tri_v2_sign(v3, v1, v) != CONCAVE))
{
return false;
}
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 572b142d044..0ce40f717d4 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -582,7 +582,7 @@ void BLI_ascii_strtolower(char *str, const size_t len)
{
size_t i;
- for (i = 0; i < len; i++)
+ for (i = 0; (i < len) && str[i]; i++)
if (str[i] >= 'A' && str[i] <= 'Z')
str[i] += 'a' - 'A';
}
@@ -591,7 +591,7 @@ void BLI_ascii_strtoupper(char *str, const size_t len)
{
size_t i;
- for (i = 0; i < len; i++)
+ for (i = 0; (i < len) && str[i]; i++)
if (str[i] >= 'a' && str[i] <= 'z')
str[i] -= 'a' - 'A';
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 4d9234e18bc..8cb9853aa47 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1354,7 +1354,13 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain)
}
for (; ima; ima = ima->id.next) {
- ima->cache = newmclipadr(fd, ima->cache);
+ ima->cache = newimaadr(fd, ima->cache);
+ if (ima->cache == NULL) {
+ ima->bindcode = 0;
+ ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
+ ima->gputexture = NULL;
+ ima->rr = NULL;
+ }
for (i = 0; i < IMA_MAX_RENDER_SLOT; i++)
ima->renders[i] = newimaadr(fd, ima->renders[i]);
@@ -3277,7 +3283,7 @@ static void direct_link_image(FileData *fd, Image *ima)
ima->cache = NULL;
/* if not restored, we keep the binded opengl index */
- if (!fd->imamap) {
+ if (!ima->cache) {
ima->bindcode = 0;
ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
ima->gputexture = NULL;
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index cbaffe2da1a..7b3ca898718 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -1258,7 +1258,7 @@ static BMFace *bm_face_create__sfme(BMesh *bm, BMFace *UNUSED(example))
*
* \return A BMFace pointer
*/
-BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2,
+BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMLoop *l_v1, BMLoop *l_v2,
BMLoop **r_l,
#ifdef USE_BMESH_HOLES
ListBase *holes,
@@ -1275,21 +1275,12 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2,
BMFace *f2;
BMLoop *l_iter, *l_first;
- BMLoop *l_v1 = NULL, *l_v2 = NULL, *l_f1 = NULL, *l_f2 = NULL;
+ BMLoop *l_f1 = NULL, *l_f2 = NULL;
BMEdge *e;
- int i, len, f1len, f2len;
+ BMVert *v1 = l_v1->v, *v2 = l_v2->v;
+ int f1len, f2len;
- /* verify that v1 and v2 are in face */
- len = f->len;
- for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f); i < len; i++, l_iter = l_iter->next) {
- if (l_iter->v == v1) l_v1 = l_iter;
- else if (l_iter->v == v2) l_v2 = l_iter;
- }
-
- if (!l_v1 || !l_v2) {
- BLI_assert(0);
- return NULL;
- }
+ BLI_assert(f == l_v1->f && f == l_v2->f);
/* allocate new edge between v1 and v2 */
e = BM_edge_create(bm, v1, v2, example, no_double ? BM_CREATE_NO_DOUBLE : BM_CREATE_NOP);
diff --git a/source/blender/bmesh/intern/bmesh_core.h b/source/blender/bmesh/intern/bmesh_core.h
index e9fd4e650cb..654698da3c6 100644
--- a/source/blender/bmesh/intern/bmesh_core.h
+++ b/source/blender/bmesh/intern/bmesh_core.h
@@ -72,14 +72,15 @@ void BM_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len
BMEdge **e_in, int e_in_len);
/* EULER API - For modifying structure */
-BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1,
- BMVert *v2, BMLoop **r_l,
+BMFace *bmesh_sfme(BMesh *bm, BMFace *f,
+ BMLoop *l1, BMLoop *l2,
+ BMLoop **r_l,
#ifdef USE_BMESH_HOLES
- ListBase *holes,
+ ListBase *holes,
#endif
- BMEdge *example,
- const bool no_double
- );
+ BMEdge *example,
+ const bool no_double
+ );
BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e);
BMEdge *bmesh_jekv(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, const bool check_edge_splice);
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index 49c8c987956..6d8dc531a32 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -252,48 +252,6 @@ BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f_a, BMFace *f_b, BMEdge *e, const
}
/**
- * \brief Connect Verts, Split Face
- *
- * connects two verts together, automatically (if very naively) finding the
- * face they both share (if there is one) and splitting it. Use this at your
- * own risk, as it doesn't handle the many complex cases it should (like zero-area faces,
- * multiple faces, etc).
- *
- * this is really only meant for cases where you don't know before hand the face
- * the two verts belong to for splitting (e.g. the subdivision operator).
- *
- * \return The newly created edge.
- */
-BMEdge *BM_verts_connect(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_f)
-{
- BMIter fiter;
- BMIter viter;
- BMVert *v_iter;
- BMFace *f_iter;
-
- /* be warned: this can do weird things in some ngon situation, see BM_face_legal_splits */
- BM_ITER_ELEM (f_iter, &fiter, v1, BM_FACES_OF_VERT) {
- BM_ITER_ELEM (v_iter, &viter, f_iter, BM_FACES_OF_VERT) {
- if (v_iter == v2) {
- BMLoop *l_new;
-
- f_iter = BM_face_split(bm, f_iter, v1, v2, &l_new, NULL, false);
-
- if (r_f) {
- *r_f = f_iter;
- }
- return l_new->e;
- }
- }
- }
-
- if (r_f) {
- *r_f = NULL;
- }
- return NULL;
-}
-
-/**
* \brief Face Split
*
* Split a face along two vertices. returns the newly made face, and sets
@@ -310,13 +268,26 @@ BMEdge *BM_verts_connect(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_f)
* if the split is successful (and the original original face will be the
* other side). NULL if the split fails.
*/
-BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l,
- BMEdge *example, const bool no_double)
+BMFace *BM_face_split(BMesh *bm, BMFace *f,
+ BMLoop *l_a, BMLoop *l_b,
+ BMLoop **r_l, BMEdge *example,
+ const bool no_double)
{
const bool has_mdisp = CustomData_has_layer(&bm->ldata, CD_MDISPS);
BMFace *f_new, *f_tmp;
- BLI_assert(v1 != v2);
+ BLI_assert(l_a != l_b);
+ BLI_assert(f == l_a->f && f == l_b->f);
+ BLI_assert(!BM_loop_is_adjacent(l_a, l_b));
+
+ /* could be an assert */
+ if (UNLIKELY(BM_loop_is_adjacent(l_a, l_b))) {
+ return NULL;
+ }
+
+ if (f != l_a->f || f != l_b->f) {
+ return NULL;
+ }
/* do we have a multires layer? */
if (has_mdisp) {
@@ -324,9 +295,9 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l
}
#ifdef USE_BMESH_HOLES
- f_new = bmesh_sfme(bm, f, v1, v2, r_l, NULL, example, no_double);
+ f_new = bmesh_sfme(bm, f, l_a, l_b, r_l, NULL, example, no_double);
#else
- f_new = bmesh_sfme(bm, f, v1, v2, r_l, example, no_double);
+ f_new = bmesh_sfme(bm, f, l_a, l_b, r_l, example, no_double);
#endif
if (f_new) {
@@ -369,7 +340,7 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l
*
* \param bm The bmesh
* \param f the original face
- * \param v1, v2 vertices which define the split edge, must be different
+ * \param l_a, l_b vertices which define the split edge, must be different
* \param cos Array of coordinates for intermediate points
* \param n Length of \a cos (must be > 0)
* \param r_l pointer which will receive the BMLoop for the first split edge (from \a v1) in the new face
@@ -379,16 +350,31 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l
* if the split is successful (and the original original face will be the
* other side). NULL if the split fails.
*/
-BMFace *BM_face_split_n(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, float cos[][3], int n,
+BMFace *BM_face_split_n(BMesh *bm, BMFace *f,
+ BMLoop *l_a, BMLoop *l_b,
+ float cos[][3], int n,
BMLoop **r_l, BMEdge *example)
{
BMFace *f_new, *f_tmp;
BMLoop *l_dummy;
BMEdge *e, *e_new;
BMVert *v_new;
+ // BMVert *v_a = l_a->v; /* UNUSED */
+ BMVert *v_b = l_b->v;
int i, j;
- BLI_assert(v1 != v2);
+ BLI_assert(l_a != l_b);
+ BLI_assert(f == l_a->f && f == l_b->f);
+ BLI_assert(!BM_loop_is_adjacent(l_a, l_b));
+
+ /* could be an assert */
+ if (UNLIKELY(BM_loop_is_adjacent(l_a, l_b))) {
+ return NULL;
+ }
+
+ if (l_a->f != l_b->f) {
+ return NULL;
+ }
f_tmp = BM_face_copy(bm, bm, f, true, true);
@@ -396,12 +382,12 @@ BMFace *BM_face_split_n(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, float cos[
r_l = &l_dummy;
#ifdef USE_BMESH_HOLES
- f_new = bmesh_sfme(bm, f, v1, v2, r_l, NULL, example, false);
+ f_new = bmesh_sfme(bm, f, l_a, l_b, r_l, NULL, example, false);
#else
- f_new = bmesh_sfme(bm, f, v1, v2, r_l, example, false);
+ f_new = bmesh_sfme(bm, f, l_a, l_b, r_l, example, false);
#endif
- /* bmesh_sfme returns in r_l a Loop for f_new going from v1 to v2.
- * The radial_next is for f and goes from v2 to v1 */
+ /* bmesh_sfme returns in r_l a Loop for f_new going from v_a to v_b.
+ * The radial_next is for f and goes from v_b to v_a */
if (f_new) {
BM_elem_attrs_copy(bm, bm, f, f_new);
@@ -409,7 +395,7 @@ BMFace *BM_face_split_n(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, float cos[
e = (*r_l)->e;
for (i = 0; i < n; i++) {
- v_new = bmesh_semv(bm, v2, e, &e_new);
+ v_new = bmesh_semv(bm, v_b, e, &e_new);
BLI_assert(v_new != NULL);
/* bmesh_semv returns in e_new the edge going from v_new to tv */
copy_v3_v3(v_new->co, cos[i]);
@@ -510,8 +496,14 @@ BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, float
BMFace *f2 = BM_faces_join(bm, faces, BLI_array_count(faces), true);
if (f2) {
BMLoop *l_new = NULL;
- if (BM_face_split(bm, f2, tv, tv2, &l_new, NULL, false)) {
- e_new = l_new->e;
+ BMLoop *l_a, *l_b;
+
+ if ((l_a = BM_face_vert_share_loop(f2, tv)) &&
+ (l_b = BM_face_vert_share_loop(f2, tv2)))
+ {
+ if (BM_face_split(bm, f2, l_a, l_b, &l_new, NULL, false)) {
+ e_new = l_new->e;
+ }
}
}
}
@@ -1058,10 +1050,10 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const bool ccw, const short check_f
/* note, this assumes joining the faces _didnt_ also remove the verts.
* the #BM_edge_rotate_check will ensure this, but its possibly corrupt state or future edits
* break this */
- if (!BM_face_split(bm, f, v1, v2, NULL, NULL, true)) {
- return NULL;
- }
- else {
+ if ((l1 = BM_face_vert_share_loop(f, v1)) &&
+ (l2 = BM_face_vert_share_loop(f, v2)) &&
+ BM_face_split(bm, f, l1, l2, NULL, NULL, true))
+ {
/* we should really be able to know the faces some other way,
* rather then fetching them back from the edge, but this is predictable
* where using the return values from face split isn't. - campbell */
@@ -1071,6 +1063,9 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const bool ccw, const short check_f
fb->head.hflag = f_hflag_prev_2;
}
}
+ else {
+ return NULL;
+ }
return e_new;
}
diff --git a/source/blender/bmesh/intern/bmesh_mods.h b/source/blender/bmesh/intern/bmesh_mods.h
index ca281c13f21..f3ed99230d7 100644
--- a/source/blender/bmesh/intern/bmesh_mods.h
+++ b/source/blender/bmesh/intern/bmesh_mods.h
@@ -35,15 +35,13 @@ bool BM_disk_dissolve(BMesh *bm, BMVert *v);
BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e, const bool do_del);
-BMEdge *BM_verts_connect(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_f);
-
BMFace *BM_face_split(BMesh *bm, BMFace *f,
- BMVert *v1, BMVert *v2,
+ BMLoop *l_a, BMLoop *l_b,
BMLoop **r_l,
BMEdge *example, const bool no_double);
BMFace *BM_face_split_n(BMesh *bm, BMFace *f,
- BMVert *v1, BMVert *v2,
+ BMLoop *l_a, BMLoop *l_b,
float cos[][3], int n,
BMLoop **r_l, BMEdge *example);
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index 7a625840891..a3aaea9e257 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -800,67 +800,67 @@ void BM_face_triangulate(BMesh *bm, BMFace *f,
BLI_assert((r_faces_new == NULL) == (r_faces_new_tot == NULL));
if (f->len == 4) {
- BMVert *v1, *v2;
+ BMLoop *l_v1, *l_v2;
l_first = BM_FACE_FIRST_LOOP(f);
switch (quad_method) {
case MOD_TRIANGULATE_QUAD_FIXED:
{
- v1 = l_first->v;
- v2 = l_first->next->next->v;
+ l_v1 = l_first;
+ l_v2 = l_first->next->next;
break;
}
case MOD_TRIANGULATE_QUAD_ALTERNATE:
{
- v1 = l_first->next->v;
- v2 = l_first->prev->v;
+ l_v1 = l_first->next;
+ l_v2 = l_first->prev;
break;
}
case MOD_TRIANGULATE_QUAD_SHORTEDGE:
{
- BMVert *v3, *v4;
+ BMLoop *l_v3, *l_v4;
float d1, d2;
- v1 = l_first->v;
- v2 = l_first->next->next->v;
- v3 = l_first->next->v;
- v4 = l_first->prev->v;
+ l_v1 = l_first;
+ l_v2 = l_first->next->next;
+ l_v3 = l_first->next;
+ l_v4 = l_first->prev;
- d1 = len_squared_v3v3(v1->co, v2->co);
- d2 = len_squared_v3v3(v3->co, v4->co);
+ d1 = len_squared_v3v3(l_v1->v->co, l_v2->v->co);
+ d2 = len_squared_v3v3(l_v3->v->co, l_v4->v->co);
if (d2 < d1) {
- v1 = v3;
- v2 = v4;
+ l_v1 = l_v3;
+ l_v2 = l_v4;
}
break;
}
case MOD_TRIANGULATE_QUAD_BEAUTY:
default:
{
- BMVert *v3, *v4;
+ BMLoop *l_v3, *l_v4;
float cost;
- v1 = l_first->next->v;
- v2 = l_first->next->next->v;
- v3 = l_first->prev->v;
- v4 = l_first->v;
+ l_v1 = l_first->next;
+ l_v2 = l_first->next->next;
+ l_v3 = l_first->prev;
+ l_v4 = l_first;
- cost = BM_verts_calc_rotate_beauty(v1, v2, v3, v4, 0, 0);
+ cost = BM_verts_calc_rotate_beauty(l_v1->v, l_v2->v, l_v3->v, l_v4->v, 0, 0);
if (cost < 0.0f) {
- v1 = v4;
- //v2 = v2;
+ l_v1 = l_v4;
+ //l_v2 = l_v2;
}
else {
- //v1 = v1;
- v2 = v3;
+ //l_v1 = l_v1;
+ l_v2 = l_v3;
}
break;
}
}
- f_new = BM_face_split(bm, f, v1, v2, &l_new, NULL, false);
+ f_new = BM_face_split(bm, f, l_v1, l_v2, &l_new, NULL, false);
copy_v3_v3(f_new->no, f->no);
if (use_tag) {
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index 16785778883..968ca5f3102 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -182,6 +182,37 @@ BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v)
}
/**
+ * Given 2 verts, find the smallest face they share and give back both loops.
+ */
+BMFace *BM_vert_pair_share_face(BMVert *v_a, BMVert *v_b,
+ BMLoop **r_l_a, BMLoop **r_l_b)
+{
+ BMLoop *l_cur_a = NULL, *l_cur_b = NULL;
+ BMFace *f_cur = NULL;
+
+ if (v_a->e && v_b->e) {
+ BMIter iter;
+ BMLoop *l_a, *l_b;
+
+ BM_ITER_ELEM (l_a, &iter, v_a, BM_LOOPS_OF_VERT) {
+ if ((f_cur == NULL) || (l_a->f->len < f_cur->len)) {
+ l_b = BM_face_vert_share_loop(l_a->f, v_b);
+ if (l_b) {
+ f_cur = l_a->f;
+ l_cur_a = l_a;
+ l_cur_b = l_b;
+ }
+ }
+ }
+ }
+
+ if (r_l_a) *r_l_a = l_cur_a;
+ if (r_l_b) *r_l_b = l_cur_b;
+
+ return f_cur;
+}
+
+/**
* Get the first loop of a vert. Uses the same initialization code for the first loop of the
* iterator API
*/
diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h
index 17c14310191..d4b6cd0e061 100644
--- a/source/blender/bmesh/intern/bmesh_queries.h
+++ b/source/blender/bmesh/intern/bmesh_queries.h
@@ -49,6 +49,8 @@ BMLoop *BM_face_other_vert_loop(BMFace *f, BMVert *v_prev, BMVert *v);
BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v);
BMLoop *BM_vert_step_fan_loop(BMLoop *l, BMEdge **e_step);
BMLoop *BM_vert_find_first_loop(BMVert *v);
+BMFace *BM_vert_pair_share_face(BMVert *v_a, BMVert *v_b,
+ BMLoop **r_l_a, BMLoop **r_l_b);
int BM_vert_edge_count_nonwire(BMVert *v);
int BM_vert_edge_count(BMVert *v);
@@ -67,6 +69,7 @@ BLI_INLINE bool BM_edge_is_contiguous(const BMEdge *e);
bool BM_edge_is_convex(const BMEdge *e);
bool BM_loop_is_convex(const BMLoop *l);
+BLI_INLINE bool BM_loop_is_adjacent(const BMLoop *l_a, const BMLoop *l_b);
float BM_loop_calc_face_angle(BMLoop *l);
void BM_loop_calc_face_normal(BMLoop *l, float r_normal[3]);
diff --git a/source/blender/bmesh/intern/bmesh_queries_inline.h b/source/blender/bmesh/intern/bmesh_queries_inline.h
index c3ee363f247..a2a0a15faad 100644
--- a/source/blender/bmesh/intern/bmesh_queries_inline.h
+++ b/source/blender/bmesh/intern/bmesh_queries_inline.h
@@ -127,5 +127,14 @@ BLI_INLINE int BM_edge_is_boundary(BMEdge *e)
}
#endif
+/**
+ * Tests whether one loop is next to another within the same face.
+ */
+BLI_INLINE bool BM_loop_is_adjacent(const BMLoop *l_a, const BMLoop *l_b)
+{
+ BLI_assert(l_a->f == l_b->f);
+ BLI_assert(l_a != l_b);
+ return (ELEM(l_b, l_a->next, l_a->prev));
+}
#endif /* __BMESH_QUERIES_INLINE_H__ */
diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c
index d0f64eb2892..3d2c8c3d020 100644
--- a/source/blender/bmesh/operators/bmo_connect.c
+++ b/source/blender/bmesh/operators/bmo_connect.c
@@ -63,7 +63,7 @@ static int bm_face_connect_verts(BMesh *bm, BMFace *f)
continue;
}
- if (l_last != l->prev && l_last != l->next) {
+ if (!BM_loop_is_adjacent(l_last, l)) {
BMLoop **l_pair = STACK_PUSH_RET(loops_split);
l_pair[0] = l_last;
l_pair[1] = l;
@@ -96,7 +96,17 @@ static int bm_face_connect_verts(BMesh *bm, BMFace *f)
}
for (i = 0; i < STACK_SIZE(verts_pair); i++) {
- f_new = BM_face_split(bm, f, verts_pair[i][0], verts_pair[i][1], &l_new, NULL, false);
+ BMLoop *l_a, *l_b;
+
+ if ((l_a = BM_face_vert_share_loop(f, verts_pair[i][0])) &&
+ (l_b = BM_face_vert_share_loop(f, verts_pair[i][1])))
+ {
+ f_new = BM_face_split(bm, f, l_a, l_b, &l_new, NULL, false);
+ }
+ else {
+ f_new = NULL;
+ }
+
f = f_new;
if (!l_new || !f_new) {
diff --git a/source/blender/bmesh/operators/bmo_connect_nonplanar.c b/source/blender/bmesh/operators/bmo_connect_nonplanar.c
index bd7a625406c..334647fc68c 100644
--- a/source/blender/bmesh/operators/bmo_connect_nonplanar.c
+++ b/source/blender/bmesh/operators/bmo_connect_nonplanar.c
@@ -86,7 +86,7 @@ static float bm_face_subset_calc_planar(BMLoop *l_first, BMLoop *l_last, const f
return delta_z;
}
-static bool bm_face_split_find(BMFace *f, BMVert *v_pair[2], float *r_angle)
+static bool bm_face_split_find(BMFace *f, BMLoop *l_pair[2], float *r_angle)
{
BMLoop *l_iter, *l_first;
BMLoop **l_arr = BLI_array_alloca(l_arr, f->len);
@@ -111,9 +111,7 @@ static bool bm_face_split_find(BMFace *f, BMVert *v_pair[2], float *r_angle)
BMLoop *l_b = l_arr[i_b];
/* check these are not touching
* (we could be smarter here) */
- if ((l_a->next != l_b) &&
- (l_a->prev != l_b))
- {
+ if (!BM_loop_is_adjacent(l_a, l_b)) {
/* first calculate normals */
float no_a[3], no_b[3];
@@ -130,8 +128,8 @@ static bool bm_face_split_find(BMFace *f, BMVert *v_pair[2], float *r_angle)
BM_face_legal_splits(f, &l_split, 1);
if (l_split[0]) {
err_best = err_test;
- v_pair[0] = l_a->v;
- v_pair[1] = l_b->v;
+ l_pair[0] = l_a;
+ l_pair[1] = l_b;
angle_best = angle_normalized_v3v3(no_a, no_b);
found = true;
@@ -151,13 +149,14 @@ static bool bm_face_split_find(BMFace *f, BMVert *v_pair[2], float *r_angle)
static bool bm_face_split_by_angle(BMesh *bm, BMFace *f, BMFace *r_f_pair[2], const float angle_limit)
{
- BMVert *v_pair[2];
+ BMLoop *l_pair[2];
float angle;
- if (bm_face_split_find(f, v_pair, &angle) && (angle > angle_limit)) {
+ if (bm_face_split_find(f, l_pair, &angle) && (angle > angle_limit)) {
BMFace *f_new;
BMLoop *l_new;
- f_new = BM_face_split(bm, f, v_pair[0], v_pair[1], &l_new, NULL, false);
+
+ f_new = BM_face_split(bm, f, l_pair[0], l_pair[1], &l_new, NULL, false);
if (f_new) {
r_f_pair[0] = f;
r_f_pair[1] = f_new;
diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c
index ae645b97874..60b96e35057 100644
--- a/source/blender/bmesh/operators/bmo_dissolve.c
+++ b/source/blender/bmesh/operators/bmo_dissolve.c
@@ -99,7 +99,7 @@ static void bm_face_split(BMesh *bm, const short oflag)
if (BMO_elem_flag_test(bm, l->next->v, oflag) == 0 &&
BMO_elem_flag_test(bm, l->prev->v, oflag) == 0)
{
- BM_face_split(bm, l->f, l->next->v, l->prev->v, NULL, NULL, true);
+ BM_face_split(bm, l->f, l->next, l->prev, NULL, NULL, true);
}
}
}
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index cc5a635092a..a771e05acfc 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -40,30 +40,32 @@
static void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op, BMOpSlot *slot_targetmap)
{
BMIter liter;
- BMLoop *l;
- BMVert *v2, *v_double;
+ BMLoop *l, *l_tar, *l_double;
bool split = false;
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- v2 = BMO_slot_map_elem_get(slot_targetmap, l->v);
- /* ok: if v2 is NULL (e.g. not in the map) then it's
+ BMVert *v_tar = BMO_slot_map_elem_get(slot_targetmap, l->v);
+ /* ok: if v_tar is NULL (e.g. not in the map) then it's
* a target vert, otherwise it's a double */
- if ((v2 && BM_vert_in_face(f, v2)) &&
- (v2 != l->prev->v) &&
- (v2 != l->next->v))
- {
- v_double = l->v;
- split = true;
- break;
+ if (v_tar) {
+ l_tar = BM_face_vert_share_loop(f, v_tar);
+
+ if (l_tar && (l_tar != l) && !BM_loop_is_adjacent(l_tar, l)) {
+ l_double = l;
+ split = true;
+ break;
+ }
}
}
- if (split && v_double != v2) {
+ if (split) {
BMLoop *l_new;
- BMFace *f2 = BM_face_split(bm, f, v_double, v2, &l_new, NULL, false);
+ BMFace *f_new;
- remdoubles_splitface(f, bm, op, slot_targetmap);
- remdoubles_splitface(f2, bm, op, slot_targetmap);
+ f_new = BM_face_split(bm, f, l_double, l_tar, &l_new, NULL, false);
+
+ remdoubles_splitface(f, bm, op, slot_targetmap);
+ remdoubles_splitface(f_new, bm, op, slot_targetmap);
}
}
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c
index b3b9cecf389..723595771a1 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -133,28 +133,23 @@ typedef struct SubDPattern {
/* connects face with smallest len, which I think should always be correct for
* edge subdivision */
-static BMEdge *connect_smallest_face(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_f_new)
+static BMEdge *connect_smallest_face(BMesh *bm, BMVert *v_a, BMVert *v_b, BMFace **r_f_new)
{
- BMIter iter, iter2;
- BMVert *v;
BMLoop *l_new;
- BMFace *f, *f_cur = NULL;
+ BMLoop *l_a, *l_b;
+ BMFace *f;
/* this isn't the best thing in the world. it doesn't handle cases where there's
* multiple faces yet. that might require a convexity test to figure out which
* face is "best" and who knows what for non-manifold conditions. */
- for (f = BM_iter_new(&iter, bm, BM_FACES_OF_VERT, v1); f; f = BM_iter_step(&iter)) {
- for (v = BM_iter_new(&iter2, bm, BM_VERTS_OF_FACE, f); v; v = BM_iter_step(&iter2)) {
- if (v == v2) {
- if (!f_cur || f->len < f_cur->len) f_cur = f;
- }
- }
- }
+ f = BM_vert_pair_share_face(v_a, v_b, &l_a, &l_b);
+
+ if (f) {
+ BMFace *f_new;
- if (f_cur) {
- f = BM_face_split(bm, f_cur, v1, v2, &l_new, NULL, false);
+ f_new = BM_face_split(bm, f, l_a, l_b, &l_new, NULL, false);
- if (r_f_new) *r_f_new = f;
+ if (r_f_new) *r_f_new = f_new;
return l_new ? l_new->e : NULL;
}
@@ -1118,7 +1113,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
if (loops_split[j][0]) {
BMFace *f_new;
BLI_assert(BM_edge_exists(loops_split[j][0]->v, loops_split[j][1]->v) == NULL);
- f_new = BM_face_split(bm, face, loops_split[j][0]->v, loops_split[j][1]->v, &l_new, NULL, false);
+ f_new = BM_face_split(bm, face, loops_split[j][0], loops_split[j][1], &l_new, NULL, false);
if (f_new) {
BMO_elem_flag_enable(bm, l_new->e, ELE_INNER);
}
diff --git a/source/blender/bmesh/operators/bmo_subdivide_edgering.c b/source/blender/bmesh/operators/bmo_subdivide_edgering.c
index d1ec06c5486..182bf0518ef 100644
--- a/source/blender/bmesh/operators/bmo_subdivide_edgering.c
+++ b/source/blender/bmesh/operators/bmo_subdivide_edgering.c
@@ -828,7 +828,7 @@ static void bm_face_slice(BMesh *bm, BMLoop *l, const int cuts)
for (i = 0; i < cuts; i++) {
/* no chance of double */
- BM_face_split(bm, l_new->f, l_new->prev->v, l_new->next->next->v, &l_new, NULL, false);
+ BM_face_split(bm, l_new->f, l_new->prev, l_new->next->next, &l_new, NULL, false);
if (l_new->f->len < l_new->radial_next->f->len) {
l_new = l_new->radial_next;
}
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 7f39cbee2c5..b10f162f2b0 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -2095,7 +2095,7 @@ static void bevel_build_trifan(BMesh *bm, BevVert *bv)
BMLoop *l_new;
BMFace *f_new;
BLI_assert(v_fan == l_fan->v);
- f_new = BM_face_split(bm, f, l_fan->v, l_fan->next->next->v, &l_new, NULL, FALSE);
+ f_new = BM_face_split(bm, f, l_fan, l_fan->next->next, &l_new, NULL, FALSE);
if (f_new->len > f->len) {
f = f_new;
@@ -2140,7 +2140,7 @@ static void bevel_build_quadstrip(BMesh *bm, BevVert *bv)
l_b = l_b->next;
}
else {
- BM_face_split(bm, f, l_a->v, l_b->v, &l_new, NULL, FALSE);
+ BM_face_split(bm, f, l_a, l_b, &l_new, NULL, FALSE);
f = l_new->f;
/* walk around the new face to get the next verts to split */
diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.c b/source/blender/bmesh/tools/bmesh_bisect_plane.c
index 6aeb26435ac..7001cfa4061 100644
--- a/source/blender/bmesh/tools/bmesh_bisect_plane.c
+++ b/source/blender/bmesh/tools/bmesh_bisect_plane.c
@@ -139,9 +139,14 @@ static void bm_face_bisect_verts(BMesh *bm, BMFace *f, const float plane[4], con
BMLoop *l_new;
if (LIKELY(STACK_SIZE(vert_split_arr) == 2)) {
+ BMLoop *l_a, *l_b;
+
+ l_a = BM_face_vert_share_loop(f, vert_split_arr[0]);
+ l_b = BM_face_vert_share_loop(f, vert_split_arr[1]);
+
/* common case, just cut the face once */
l_new = NULL;
- BM_face_split(bm, f, vert_split_arr[0], vert_split_arr[1], &l_new, NULL, true);
+ BM_face_split(bm, f, l_a, l_b, &l_new, NULL, true);
if (l_new) {
if (oflag_center) {
BMO_elem_flag_enable(bm, l_new->e, oflag_center);
@@ -254,9 +259,9 @@ static void bm_face_bisect_verts(BMesh *bm, BMFace *f, const float plane[4], con
/* in fact this simple test is good enough,
* test if the loops are adjacent */
- if (found && (l_a->next != l_b && l_a->prev != l_b)) {
+ if (found && !BM_loop_is_adjacent(l_a, l_b)) {
BMFace *f_tmp;
- f_tmp = BM_face_split(bm, face_split_arr[j], l_a->v, l_b->v, NULL, NULL, true);
+ f_tmp = BM_face_split(bm, face_split_arr[j], l_a, l_b, NULL, NULL, true);
if (f_tmp) {
if (f_tmp != face_split_arr[j]) {
STACK_PUSH(face_split_arr, f_tmp);
diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
index 3ee238ad54f..292978cd247 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
@@ -358,7 +358,7 @@ static bool bm_decim_triangulate_begin(BMesh *bm)
* - if there is a quad that has a free standing edge joining it along
* where we want to split the face, there isnt a good way we can handle this.
* currently that edge will get removed when joining the tris back into a quad. */
- f_new = BM_face_split(bm, f, l_a->v, l_b->v, &l_new, NULL, false);
+ f_new = BM_face_split(bm, f, l_a, l_b, &l_new, NULL, false);
if (f_new) {
/* the value of this doesn't matter, only that the 2 loops match and have unique values */
diff --git a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
index 868caa49ec7..092a004aece 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
@@ -144,7 +144,7 @@ static bool bm_vert_dissolve_fan(BMesh *bm, BMVert *v)
if (l->f->len > 3) {
BMLoop *l_new;
BLI_assert(l->prev->v != l->next->v);
- BM_face_split(bm, l->f, l->prev->v, l->next->v, &l_new, NULL, true);
+ BM_face_split(bm, l->f, l->prev, l->next, &l_new, NULL, true);
BM_elem_flag_merge_into(l_new->e, l->e, l->prev->e);
}
}
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index f230adce28c..559b180189f 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -942,7 +942,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
float ctime = BKE_scene_frame_get_from_ctime(scene, *it);
CFRA = BKE_scene_frame_get_from_ctime(scene, *it);
- //BKE_scene_update_for_newframe_viewport(G.main,scene,scene->lay);
+ //BKE_scene_update_for_newframe(G.main->eval_ctx, G.main,scene,scene->lay);
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL);
if (bone) {
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 2e805ce18f1..f5b81c6f6b0 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -160,7 +160,7 @@ Mesh *bc_get_mesh_copy(Scene *scene, Object *ob, BC_export_mesh_type export_mesh
}
}
else {
- dm = mesh_create_derived((Mesh *)ob->data, ob, NULL);
+ dm = mesh_create_derived((Mesh *)ob->data, NULL);
}
tmpmesh = BKE_mesh_add(G.main, "ColladaMesh"); // name is not important here
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index ad745155286..5e93fda0cd4 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -1042,9 +1042,11 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, bActionGro
* - this will also affect things like Drivers, and also works for Bone Constraints
*/
if (ads && owner_id) {
- if ((ads->filterflag & ADS_FILTER_ONLYSEL) || (ads->filterflag & ADS_FILTER_INCL_HIDDEN) == 0) {
- if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode))
- continue;
+ if ((filter_mode & ANIMFILTER_TMP_IGNORE_ONLYSEL) == 0) {
+ if ((ads->filterflag & ADS_FILTER_ONLYSEL) || (ads->filterflag & ADS_FILTER_INCL_HIDDEN) == 0) {
+ if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode))
+ continue;
+ }
}
}
@@ -1541,21 +1543,17 @@ static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBase *anim_data,
{
bNode *node;
size_t items = 0;
- int group_filter_mode = filter_mode & ~ADS_FILTER_ONLYSEL;
items += animdata_filter_ds_nodetree_group(ac, anim_data, ads, owner_id, ntree, filter_mode);
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP) {
if (node->id) {
- int filterflag = ads->filterflag;
- if ((filter_mode & ADS_FILTER_ONLYSEL) && (node->flag & NODE_SELECT) == 0) {
+ if ((ads->filterflag & ADS_FILTER_ONLYSEL) && (node->flag & NODE_SELECT) == 0) {
continue;
}
- /* TODO(sergey): A bit creepy, but this flag is not used from threads anyway. */
- ads->filterflag &= ~ADS_FILTER_ONLYSEL;
- items += animdata_filter_ds_nodetree_group(ac, anim_data, ads, owner_id, (bNodeTree *) node->id, group_filter_mode);
- ads->filterflag = filterflag;
+ items += animdata_filter_ds_nodetree_group(ac, anim_data, ads, owner_id, (bNodeTree *) node->id,
+ filter_mode | ANIMFILTER_TMP_IGNORE_ONLYSEL);
}
}
}
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index dd1995a5428..48440d10ae3 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -59,6 +59,7 @@ extern const unsigned char stipple_halftone[128];
extern const unsigned char stipple_quarttone[128];
extern const unsigned char stipple_diag_stripes_pos[128];
extern const unsigned char stipple_diag_stripes_neg[128];
+extern const unsigned char stipple_checker_8px[128];
/**
* Draw a lined (non-looping) arc with the given
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 8b9bb0a4ab0..dff5069d991 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -225,7 +225,10 @@ typedef enum eAnimFilter_Flags {
ANIMFILTER_NODUPLIS = (1 << 11),
/* for checking if we should keep some collapsed channel around (internal use only!) */
- ANIMFILTER_TMP_PEEK = (1 << 30)
+ ANIMFILTER_TMP_PEEK = (1 << 30),
+
+ /* ignore ONLYSEL flag from filterflag, (internal use only!) */
+ ANIMFILTER_TMP_IGNORE_ONLYSEL = (1 << 31)
} eAnimFilter_Flags;
/* ---------- Flag Checking Macros ------------ */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index cfd6d74dcef..735e7f35d61 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -726,8 +726,8 @@ void UI_exit(void);
#define UI_LAYOUT_MENU 2
#define UI_LAYOUT_TOOLBAR 3
-#define UI_UNIT_X U.widget_unit
-#define UI_UNIT_Y U.widget_unit
+#define UI_UNIT_X ((void)0, U.widget_unit)
+#define UI_UNIT_Y ((void)0, U.widget_unit)
#define UI_LAYOUT_ALIGN_EXPAND 0
#define UI_LAYOUT_ALIGN_LEFT 1
@@ -748,6 +748,10 @@ void UI_exit(void);
#define UI_LAYOUT_OP_SHOW_TITLE 1
#define UI_LAYOUT_OP_SHOW_EMPTY 2
+/* used for transp checkers */
+#define UI_ALPHA_CHECKER_DARK 100
+#define UI_ALPHA_CHECKER_LIGHT 160
+
/* flags to set which corners will become rounded:
*
* 1------2
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index b6f93726bfc..3301f1f1e5a 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -935,11 +935,11 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
/* first background, to show tranparency */
- glColor4ub(UI_TRANSP_DARK, UI_TRANSP_DARK, UI_TRANSP_DARK, 255);
+ glColor4ub(UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, 255);
glRectf(x1, y1, x1 + sizex, y1 + sizey);
glEnable(GL_POLYGON_STIPPLE);
- glColor4ub(UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, 255);
- glPolygonStipple(checker_stipple_sml);
+ glColor4ub(UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, 255);
+ glPolygonStipple(stipple_checker_8px);
glRectf(x1, y1, x1 + sizex, y1 + sizey);
glDisable(GL_POLYGON_STIPPLE);
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index e11b93ca69b..5500df624cf 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -544,11 +544,6 @@ void ui_widget_color_init(struct ThemeUI *tui);
void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state, bool use_sep);
void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state);
-extern const unsigned char checker_stipple_sml[32 * 32 / 8];
-/* used for transp checkers */
-#define UI_TRANSP_DARK 100
-#define UI_TRANSP_LIGHT 160
-
#define UI_TEXT_MARGIN_X 0.4f
/* interface_style.c */
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 5c2ce7ad635..477b7c4e8f3 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -181,18 +181,6 @@ static const unsigned int check_tria_face[4][3] = {
{3, 2, 4}, {3, 4, 5}, {1, 0, 3}, {0, 2, 3}
};
-GLubyte const checker_stipple_sml[32 * 32 / 8] =
-{
- 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
- 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
- 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
- 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
- 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
- 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
- 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
- 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
-};
-
/* ************************************************* */
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3)
@@ -681,15 +669,15 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
float x_mid = 0.0f; /* used for dumb clamping of values */
/* dark checkers */
- glColor4ub(UI_TRANSP_DARK, UI_TRANSP_DARK, UI_TRANSP_DARK, 255);
+ glColor4ub(UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, 255);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v);
glDrawArrays(GL_POLYGON, 0, wtb->totvert);
/* light checkers */
glEnable(GL_POLYGON_STIPPLE);
- glColor4ub(UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, 255);
- glPolygonStipple(checker_stipple_sml);
+ glColor4ub(UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, 255);
+ glPolygonStipple(stipple_checker_8px);
glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v);
glDrawArrays(GL_POLYGON, 0, wtb->totvert);
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 6b60e5ed390..4cf4cd1ddba 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -590,8 +590,6 @@ static float *threaded_mask_rasterize(Mask *mask, const int width, const int hei
task_pool = BLI_task_pool_create(task_scheduler, &state);
- BLI_begin_threaded_malloc();
-
scanlines_per_thread = height / num_threads;
for (i = 0; i < num_threads; i++) {
ThreadedMaskRasterizeData *data = MEM_mallocN(sizeof(ThreadedMaskRasterizeData),
@@ -614,7 +612,6 @@ static float *threaded_mask_rasterize(Mask *mask, const int width, const int hei
/* Free memory. */
BLI_task_pool_free(task_pool);
- BLI_end_threaded_malloc();
BKE_maskrasterize_handle_free(handle);
return buffer;
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 64175c133ea..0d1e43a709b 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -2237,6 +2237,7 @@ static void knife_make_chain_cut(KnifeTool_OpData *kcd, BMFace *f, ListBase *cha
BMesh *bm = kcd->em->bm;
KnifeEdge *kfe, *kfelast;
BMVert *v1, *v2;
+ BMLoop *l_v1, *l_v2;
BMFace *f_new;
Ref *ref;
KnifeVert *kfv, *kfvprev;
@@ -2262,28 +2263,36 @@ static void knife_make_chain_cut(KnifeTool_OpData *kcd, BMFace *f, ListBase *cha
}
BLI_assert(i == nco);
l_new = NULL;
- if (nco == 0) {
- /* Want to prevent creating two-sided polygons */
- if (v1 == v2 || BM_edge_exists(v1, v2)) {
- f_new = NULL;
+
+ if ((l_v1 = BM_face_vert_share_loop(f, v1)) &&
+ (l_v2 = BM_face_vert_share_loop(f, v2)))
+ {
+ if (nco == 0) {
+ /* Want to prevent creating two-sided polygons */
+ if (v1 == v2 || BM_edge_exists(v1, v2)) {
+ f_new = NULL;
+ }
+ else {
+ f_new = BM_face_split(bm, f, l_v1, l_v2, &l_new, NULL, true);
+ }
}
else {
- f_new = BM_face_split(bm, f, v1, v2, &l_new, NULL, true);
- }
- }
- else {
- f_new = BM_face_split_n(bm, f, v1, v2, cos, nco, &l_new, NULL);
- if (f_new) {
- /* Now go through lnew chain matching up chain kv's and assign real v's to them */
- for (l_iter = l_new->next, i = 0; i < nco; l_iter = l_iter->next, i++) {
- BLI_assert(equals_v3v3(cos[i], l_iter->v->co));
- if (kcd->select_result) {
- BM_edge_select_set(bm, l_iter->e, true);
+ f_new = BM_face_split_n(bm, f, l_v1, l_v2, cos, nco, &l_new, NULL);
+ if (f_new) {
+ /* Now go through lnew chain matching up chain kv's and assign real v's to them */
+ for (l_iter = l_new->next, i = 0; i < nco; l_iter = l_iter->next, i++) {
+ BLI_assert(equals_v3v3(cos[i], l_iter->v->co));
+ if (kcd->select_result) {
+ BM_edge_select_set(bm, l_iter->e, true);
+ }
+ kverts[i]->v = l_iter->v;
}
- kverts[i]->v = l_iter->v;
}
}
}
+ else {
+ f_new = NULL;
+ }
/* the select chain above doesnt account for the first loop */
if (kcd->select_result) {
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index 55564703a87..b8a96bba874 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -209,7 +209,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
Mesh *me = (Mesh *)ob->data;
MultiresModifierData tmp_mmd = *mmd;
- DerivedMesh *cddm = CDDM_from_mesh(me, ob);
+ DerivedMesh *cddm = CDDM_from_mesh(me);
if (mmd->lvl > 0) {
*lvl = mmd->lvl;
@@ -234,7 +234,7 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l
Mesh *me = (Mesh *)ob->data;
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
MultiresModifierData tmp_mmd = *mmd;
- DerivedMesh *cddm = CDDM_from_mesh(me, ob);
+ DerivedMesh *cddm = CDDM_from_mesh(me);
DerivedMesh *dm;
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 230c3a11108..9cdb6de99b0 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -137,6 +137,16 @@ const GLubyte stipple_diag_stripes_neg[128] = {
0x0f, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x1f, 0xe0,
0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80};
+const GLubyte stipple_checker_8px[128] = {
+ 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
+ 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
+ 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
+ 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
+ 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
+ 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
+ 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
+ 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255};
+
void fdrawbezier(float vec[4][3])
{
@@ -204,22 +214,12 @@ void fdrawcheckerboard(float x1, float y1, float x2, float y2)
{
unsigned char col1[4] = {40, 40, 40}, col2[4] = {50, 50, 50};
- GLubyte checker_stipple[32 * 32 / 8] = {
- 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
- 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
- 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
- 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
- 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
- 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
- 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
- 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255};
-
glColor3ubv(col1);
glRectf(x1, y1, x2, y2);
glColor3ubv(col2);
glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple(checker_stipple);
+ glPolygonStipple(stipple_checker_8px);
glRectf(x1, y1, x2, y2);
glDisable(GL_POLYGON_STIPPLE);
}
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index 80b844464db..16845bb10fb 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -116,7 +116,7 @@ static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track,
glBegin(GL_LINE_STRIP);
}
-static void tracking_segment_end_cb(void *UNUSED(userdata))
+static void tracking_segment_end_cb(void *UNUSED(userdata), int UNUSED(coord))
{
glEnd();
@@ -151,7 +151,7 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track,
}
}
-static void draw_tracks_curves(View2D *v2d, SpaceClip *sc)
+static void draw_tracks_motion_curves(View2D *v2d, SpaceClip *sc)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
@@ -191,6 +191,108 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc)
&userdata, tracking_segment_knot_cb, NULL, NULL);
}
+typedef struct TrackErrorCurveUserData {
+ MovieTracking *tracking;
+ MovieTrackingObject *tracking_object;
+ MovieTrackingTrack *active_track;
+ bool matrix_initialized;
+ int matrix_frame;
+ float projection_matrix[4][4];
+ int width, height;
+ float aspy;
+} TrackErrorCurveUserData;
+
+static void tracking_error_segment_point_cb(void *userdata,
+ MovieTrackingTrack *track, MovieTrackingMarker *marker,
+ int coord, int scene_framenr, float UNUSED(value))
+{
+ if (coord == 1) {
+ TrackErrorCurveUserData *data = (TrackErrorCurveUserData *) userdata;
+ float reprojected_position[4], bundle_position[4], marker_position[2], delta[2];
+ float reprojection_error;
+
+ if (!data->matrix_initialized || data->matrix_frame != scene_framenr) {
+ BKE_tracking_get_projection_matrix(data->tracking, data->tracking_object,
+ scene_framenr, data->width, data->height,
+ data->projection_matrix);
+ }
+
+ copy_v3_v3(bundle_position, track->bundle_pos);
+ bundle_position[3] = 1;
+
+ mul_v4_m4v4(reprojected_position, data->projection_matrix, bundle_position);
+ reprojected_position[0] = (reprojected_position[0] /
+ (reprojected_position[3] * 2.0f) + 0.5f) * data->width;
+ reprojected_position[1] = (reprojected_position[1] /
+ (reprojected_position[3] * 2.0f) + 0.5f) * data->height * data->aspy;
+
+ BKE_tracking_distort_v2(data->tracking, reprojected_position, reprojected_position);
+
+ marker_position[0] = (marker->pos[0] + track->offset[0]) * data->width;
+ marker_position[1] = (marker->pos[1] + track->offset[1]) * data->height * data->aspy;
+
+ sub_v2_v2v2(delta, reprojected_position, marker_position);
+ reprojection_error = len_v2(delta);
+
+ glVertex2f(scene_framenr, reprojection_error);
+ }
+}
+
+static void tracking_error_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord)
+{
+ if (coord == 1) {
+ TrackErrorCurveUserData *data = (TrackErrorCurveUserData *) userdata;
+ float col[4] = {0.0f, 0.0f, 1.0f, 1.0f};
+
+ if (track == data->active_track) {
+ col[3] = 1.0f;
+ glLineWidth(2.0f);
+ }
+ else {
+ col[3] = 0.5f;
+ glLineWidth(1.0f);
+ }
+
+ glColor4fv(col);
+
+ glBegin(GL_LINE_STRIP);
+ }
+}
+
+static void tracking_error_segment_end_cb(void *UNUSED(userdata), int coord)
+{
+ if (coord == 1) {
+ glEnd();
+ glLineWidth(1.0f);
+ }
+}
+
+static void draw_tracks_error_curves(SpaceClip *sc)
+{
+ MovieClip *clip = ED_space_clip_get_clip(sc);
+ MovieTracking *tracking = &clip->tracking;
+ TrackErrorCurveUserData data;
+
+ data.tracking = tracking;
+ data.tracking_object = BKE_tracking_object_get_active(tracking);
+ data.active_track = BKE_tracking_track_get_active(tracking);
+ data.matrix_initialized = false;
+ BKE_movieclip_get_size(clip, &sc->user, &data.width, &data.height);
+ data.aspy = 1.0f / tracking->camera.pixel_aspect;
+
+ if (!data.width || !data.height) {
+ return;
+ }
+
+ clip_graph_tracking_values_iterate(sc,
+ (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
+ (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
+ &data,
+ tracking_error_segment_point_cb,
+ tracking_error_segment_start_cb,
+ tracking_error_segment_end_cb);
+}
+
static void draw_frame_curves(SpaceClip *sc)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -237,8 +339,11 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
UI_view2d_grid_free(grid);
if (clip) {
- if (sc->flag & SC_SHOW_GRAPH_TRACKS)
- draw_tracks_curves(v2d, sc);
+ if (sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION)
+ draw_tracks_motion_curves(v2d, sc);
+
+ if (sc->flag & SC_SHOW_GRAPH_TRACKS_ERROR)
+ draw_tracks_error_curves(sc);
if (sc->flag & SC_SHOW_GRAPH_FRAMES)
draw_frame_curves(sc);
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index e0062ecd243..44261b8b500 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -72,6 +72,16 @@ static int ED_space_clip_graph_poll(bContext *C)
return FALSE;
}
+static int clip_graph_knots_poll(bContext *C)
+{
+ if (ED_space_clip_graph_poll(C)) {
+ SpaceClip *sc = CTX_wm_space_clip(C);
+
+ return (sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) != 0;
+ }
+ return FALSE;
+}
+
typedef struct {
int action;
} SelectUserData;
@@ -130,7 +140,7 @@ static void find_nearest_tracking_segment_cb(void *userdata, MovieTrackingTrack
copy_v2_v2(data->prev_co, co);
}
-static void find_nearest_tracking_segment_end_cb(void *userdata)
+static void find_nearest_tracking_segment_end_cb(void *userdata, int UNUSED(coord))
{
MouseSelectUserData *data = userdata;
@@ -302,7 +312,7 @@ void CLIP_OT_graph_select(wmOperatorType *ot)
/* api callbacks */
ot->exec = select_exec;
ot->invoke = select_invoke;
- ot->poll = ED_space_clip_graph_poll;
+ ot->poll = clip_graph_knots_poll;
/* flags */
ot->flag = OPTYPE_UNDO;
@@ -394,7 +404,7 @@ void CLIP_OT_graph_select_border(wmOperatorType *ot)
ot->invoke = WM_border_select_invoke;
ot->exec = border_select_graph_exec;
ot->modal = WM_border_select_modal;
- ot->poll = ED_space_clip_graph_poll;
+ ot->poll = clip_graph_knots_poll;
/* flags */
ot->flag = OPTYPE_UNDO;
@@ -461,7 +471,7 @@ void CLIP_OT_graph_select_all_markers(wmOperatorType *ot)
/* api callbacks */
ot->exec = graph_select_all_markers_exec;
- ot->poll = ED_space_clip_graph_poll;
+ ot->poll = clip_graph_knots_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -496,7 +506,7 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot)
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = delete_curve_exec;
- ot->poll = ED_space_clip_tracking_poll;
+ ot->poll = clip_graph_knots_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -536,7 +546,7 @@ void CLIP_OT_graph_delete_knot(wmOperatorType *ot)
/* api callbacks */
ot->exec = delete_knot_exec;
- ot->poll = ED_space_clip_graph_poll;
+ ot->poll = clip_graph_knots_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h
index af9d8f97138..811f8e2eaab 100644
--- a/source/blender/editors/space_clip/clip_intern.h
+++ b/source/blender/editors/space_clip/clip_intern.h
@@ -125,12 +125,12 @@ void ED_clip_tool_props_register(struct ARegionType *art);
void clip_graph_tracking_values_iterate_track(struct SpaceClip *sc, struct MovieTrackingTrack *track, void *userdata,
void (*func)(void *userdata, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int coord, int scene_framenr, float val),
void (*segment_start)(void *userdata, struct MovieTrackingTrack *track, int coord),
- void (*segment_end)(void *userdata));
+ void (*segment_end)(void *userdata, int coord));
void clip_graph_tracking_values_iterate(struct SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata,
void (*func)(void *userdata, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int coord, int scene_framenr, float val),
void (*segment_start)(void *userdata, struct MovieTrackingTrack *track, int coord),
- void (*segment_end)(void *userdata));
+ void (*segment_end)(void *userdata, int coord));
void clip_graph_tracking_iterate(struct SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata,
void (*func)(void *userdata, struct MovieTrackingMarker *marker));
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index 060531ae82c..4b90fa5839f 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -70,7 +70,7 @@ void clip_graph_tracking_values_iterate_track(
void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, int coord,
int scene_framenr, float val),
void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord),
- void (*segment_end)(void *userdata))
+ void (*segment_end)(void *userdata, int coord))
{
MovieClip *clip = ED_space_clip_get_clip(sc);
int width, height, coord;
@@ -89,7 +89,7 @@ void clip_graph_tracking_values_iterate_track(
if (marker->flag & MARKER_DISABLED) {
if (open) {
if (segment_end)
- segment_end(userdata);
+ segment_end(userdata, coord);
open = false;
}
@@ -121,7 +121,7 @@ void clip_graph_tracking_values_iterate_track(
if (open) {
if (segment_end)
- segment_end(userdata);
+ segment_end(userdata, coord);
}
}
}
@@ -131,7 +131,7 @@ void clip_graph_tracking_values_iterate(
void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker,
int coord, int scene_framenr, float val),
void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord),
- void (*segment_end)(void *userdata))
+ void (*segment_end)(void *userdata, int coord))
{
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 2cabb595fb7..e1262d0d7b8 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -247,7 +247,7 @@ static SpaceLink *clip_new(const bContext *C)
sc = MEM_callocN(sizeof(SpaceClip), "initclip");
sc->spacetype = SPACE_CLIP;
sc->flag = SC_SHOW_MARKER_PATTERN | SC_SHOW_TRACK_PATH | SC_MANUAL_CALIBRATION |
- SC_SHOW_GRAPH_TRACKS | SC_SHOW_GRAPH_FRAMES | SC_SHOW_GPENCIL;
+ SC_SHOW_GRAPH_TRACKS_MOTION | SC_SHOW_GRAPH_FRAMES | SC_SHOW_GPENCIL;
sc->zoom = 1.0f;
sc->path_length = 20;
sc->scopes.track_preview_height = 120;
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 76305aaabaa..672549f0402 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -165,8 +165,10 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar, float zoomx,
void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_default_view, int channels, int x, int y,
const unsigned char cp[4], const float fp[4], const float linearcol[4], int *zp, float *zpf)
{
+ rcti color_rect;
char str[256];
- float dx = 6;
+ int dx = 6;
+ const int dy = 0.3f * UI_UNIT_Y;
/* text colors */
/* XXX colored text not allowed in Blender UI */
#if 0
@@ -193,21 +195,21 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
glColor3ub(255, 255, 255);
BLI_snprintf(str, sizeof(str), "X:%-4d Y:%-4d |", x, y);
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_Y, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
if (zp) {
glColor3ub(255, 255, 255);
BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f + 0.5f * (((float)*zp) / (float)0x7fffffff));
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
}
if (zpf) {
glColor3ub(255, 255, 255);
BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf);
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
}
@@ -220,7 +222,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLI_snprintf(str, sizeof(str), " R:%-3d", cp[0]);
else
BLI_snprintf(str, sizeof(str), " R:-");
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
@@ -231,7 +233,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLI_snprintf(str, sizeof(str), " G:%-3d", cp[1]);
else
BLI_snprintf(str, sizeof(str), " G:-");
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
@@ -242,7 +244,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLI_snprintf(str, sizeof(str), " B:%-3d", cp[2]);
else
BLI_snprintf(str, sizeof(str), " B:-");
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
@@ -254,7 +256,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLI_snprintf(str, sizeof(str), " A:%-3d", cp[3]);
else
BLI_snprintf(str, sizeof(str), "- ");
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
}
@@ -274,7 +276,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, &scene->view_settings, &scene->display_settings);
BLI_snprintf(str, sizeof(str), " | CM R:%-.4f G:%-.4f B:%-.4f", rgba[0], rgba[1], rgba[2]);
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
}
@@ -316,23 +318,47 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
}
glDisable(GL_BLEND);
- glColor3fv(finalcol);
dx += 0.25f * UI_UNIT_X;
- glBegin(GL_QUADS);
- glVertex2f(dx, 0.15f * UI_UNIT_Y);
- glVertex2f(dx, 0.85f * UI_UNIT_Y);
- glVertex2f(dx + 1.5f * UI_UNIT_X, 0.85 * UI_UNIT_Y);
- glVertex2f(dx + 1.5f * UI_UNIT_X, 0.15f * UI_UNIT_Y);
- glEnd();
+
+ BLI_rcti_init(&color_rect, dx, dx + (1.5f * UI_UNIT_X), 0.15f * UI_UNIT_Y, 0.85f * UI_UNIT_Y);
+
+ if (channels == 4) {
+ rcti color_rect_half;
+ int color_quater_x, color_quater_y;
+
+ color_rect_half = color_rect;
+ color_rect_half.xmax = BLI_rcti_cent_x(&color_rect);
+ glRecti(color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
+
+ color_rect_half = color_rect;
+ color_rect_half.xmin = BLI_rcti_cent_x(&color_rect);
+
+ color_quater_x = BLI_rcti_cent_x(&color_rect_half);
+ color_quater_y = BLI_rcti_cent_y(&color_rect_half);
+
+ glColor4ub(UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, 255);
+ glRecti(color_rect_half.xmin, color_rect_half.ymin, color_rect_half.xmax, color_rect_half.ymax);
+
+ glColor4ub(UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, 255);
+ glRecti(color_quater_x, color_quater_y, color_rect_half.xmax, color_rect_half.ymax);
+ glRecti(color_rect_half.xmin, color_rect_half.ymin, color_quater_x, color_quater_y);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glColor4f(UNPACK3(finalcol), fp ? fp[3] : (cp[3] / 255.0f));
+ glRecti(color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
+ glDisable(GL_BLEND);
+ }
+ else {
+ glColor3fv(finalcol);
+ glRecti(color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
+ }
/* draw outline */
glColor3ub(128, 128, 128);
- glBegin(GL_LINE_LOOP);
- glVertex2f(dx, 0.15f * UI_UNIT_Y);
- glVertex2f(dx, 0.85f * UI_UNIT_Y);
- glVertex2f(dx + 1.5f * UI_UNIT_X, 0.85f * UI_UNIT_Y);
- glVertex2f(dx + 1.5f * UI_UNIT_X, 0.15f * UI_UNIT_Y);
- glEnd();
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ glRecti(color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
dx += 1.75f * UI_UNIT_X;
@@ -348,12 +374,12 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
}
BLI_snprintf(str, sizeof(str), "V:%-.4f", val);
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
BLI_snprintf(str, sizeof(str), " L:%-.4f", lum);
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
}
@@ -362,22 +388,22 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
rgb_to_yuv(finalcol[0], finalcol[1], finalcol[2], &lum, &u, &v);
BLI_snprintf(str, sizeof(str), "H:%-.4f", hue);
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
BLI_snprintf(str, sizeof(str), " S:%-.4f", sat);
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
BLI_snprintf(str, sizeof(str), " V:%-.4f", val);
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
BLI_snprintf(str, sizeof(str), " L:%-.4f", lum);
- BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
+ BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
}
diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h
index b5426fe15e1..967bcec57c5 100644
--- a/source/blender/editors/space_info/info_intern.h
+++ b/source/blender/editors/space_info/info_intern.h
@@ -37,6 +37,7 @@ struct SpaceInfo;
struct wmOperatorType;
struct ReportList;
+void FILE_OT_autopack_toggle(struct wmOperatorType *ot);
void FILE_OT_pack_all(struct wmOperatorType *ot);
void FILE_OT_unpack_all(struct wmOperatorType *ot);
void FILE_OT_unpack_item(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index 6c76ba64893..ace3b8d5393 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -70,7 +70,7 @@
#include "info_intern.h"
-/********************* pack blend file libararies operator *********************/
+/********************* pack blend file libaries operator *********************/
static int pack_libraries_exec(bContext *C, wmOperator *op)
{
@@ -124,6 +124,36 @@ void FILE_OT_unpack_libraries(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+/********************* toogle auto-pack operator *********************/
+
+static int autopack_toggle_exec(bContext *C, wmOperator *op)
+{
+ Main *bmain = CTX_data_main(C);
+
+ if (G.fileflags & G_AUTOPACK) {
+ G.fileflags &= ~G_AUTOPACK;
+ }
+ else {
+ packAll(bmain, op->reports);
+ G.fileflags |= G_AUTOPACK;
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void FILE_OT_autopack_toggle(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Automatically Pack Into .blend";
+ ot->idname = "FILE_OT_autopack_toggle";
+ ot->description = "Automatically pack all external files into the .blend file";
+
+ /* api callbacks */
+ ot->exec = autopack_toggle_exec;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
/********************* pack all operator *********************/
@@ -168,7 +198,7 @@ static int pack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
void FILE_OT_pack_all(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Pack All";
+ ot->name = "Pack All Into .blend";
ot->idname = "FILE_OT_pack_all";
ot->description = "Pack all used external files into the .blend";
@@ -214,7 +244,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
count = countPackedFiles(bmain);
if (!count) {
- BKE_report(op->reports, RPT_WARNING, "No packed files (auto-pack disabled)");
+ BKE_report(op->reports, RPT_WARNING, "No packed files to unpack");
G.fileflags &= ~G_AUTOPACK;
return OPERATOR_CANCELLED;
}
@@ -238,7 +268,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
void FILE_OT_unpack_all(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Unpack All";
+ ot->name = "Unpack All Into Files";
ot->idname = "FILE_OT_unpack_all";
ot->description = "Unpack all files packed into this .blend to external ones";
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 96e0de17918..c029a4bf0bc 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -179,6 +179,7 @@ static void info_main_area_draw(const bContext *C, ARegion *ar)
static void info_operatortypes(void)
{
+ WM_operatortype_append(FILE_OT_autopack_toggle);
WM_operatortype_append(FILE_OT_pack_all);
WM_operatortype_append(FILE_OT_pack_libraries);
WM_operatortype_append(FILE_OT_unpack_all);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 5b8c4a92555..02e981f2ffd 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -6201,7 +6201,7 @@ static void get_local_bounds(Object *ob, float center[3], float size[3])
}
#endif
-static void draw_bb_quadric(BoundBox *bb, char type)
+static void draw_bb_quadric(BoundBox *bb, char type, bool around_origin)
{
float size[3], cent[3];
GLUquadricObj *qobj = gluNewQuadric();
@@ -6212,9 +6212,14 @@ static void draw_bb_quadric(BoundBox *bb, char type)
size[1] = 0.5f * fabsf(bb->vec[0][1] - bb->vec[2][1]);
size[2] = 0.5f * fabsf(bb->vec[0][2] - bb->vec[1][2]);
- cent[0] = 0.5f * (bb->vec[0][0] + bb->vec[4][0]);
- cent[1] = 0.5f * (bb->vec[0][1] + bb->vec[2][1]);
- cent[2] = 0.5f * (bb->vec[0][2] + bb->vec[1][2]);
+ if (around_origin) {
+ zero_v3(cent);
+ }
+ else {
+ cent[0] = 0.5f * (bb->vec[0][0] + bb->vec[4][0]);
+ cent[1] = 0.5f * (bb->vec[0][1] + bb->vec[2][1]);
+ cent[2] = 0.5f * (bb->vec[0][2] + bb->vec[1][2]);
+ }
glPushMatrix();
if (type == OB_BOUND_SPHERE) {
@@ -6278,11 +6283,37 @@ static void draw_bounding_volume(Scene *scene, Object *ob, char type)
BKE_boundbox_init_from_minmax(bb, min, max);
}
- if (bb == NULL) return;
-
- if (type == OB_BOUND_BOX) draw_box(bb->vec);
- else draw_bb_quadric(bb, type);
+ if (bb == NULL)
+ return;
+ if (ob->gameflag & OB_BOUNDS) { /* bounds need to be drawn around origin for game engine */
+
+ if (type == OB_BOUND_BOX) {
+ float vec[8][3], size[3];
+
+ size[0] = 0.5f * fabsf(bb->vec[0][0] - bb->vec[4][0]);
+ size[1] = 0.5f * fabsf(bb->vec[0][1] - bb->vec[2][1]);
+ size[2] = 0.5f * fabsf(bb->vec[0][2] - bb->vec[1][2]);
+
+ vec[0][0] = vec[1][0] = vec[2][0] = vec[3][0] = -size[0];
+ vec[4][0] = vec[5][0] = vec[6][0] = vec[7][0] = +size[0];
+ vec[0][1] = vec[1][1] = vec[4][1] = vec[5][1] = -size[1];
+ vec[2][1] = vec[3][1] = vec[6][1] = vec[7][1] = +size[1];
+ vec[0][2] = vec[3][2] = vec[4][2] = vec[7][2] = -size[2];
+ vec[1][2] = vec[2][2] = vec[5][2] = vec[6][2] = +size[2];
+
+ draw_box(vec);
+ }
+ else {
+ draw_bb_quadric(bb, type, true);
+ }
+ }
+ else {
+ if (type == OB_BOUND_BOX)
+ draw_box(bb->vec);
+ else
+ draw_bb_quadric(bb, type, false);
+ }
}
static void drawtexspace(Object *ob)
@@ -6565,6 +6596,48 @@ static void draw_object_matcap_check(Scene *scene, View3D *v3d, Object *ob)
}
+static void draw_rigidbody_shape(Object *ob)
+{
+ BoundBox *bb = NULL;
+ float size[3], vec[8][3];
+
+ if (ob->type == OB_MESH) {
+ bb = BKE_mesh_boundbox_get(ob);
+ }
+
+ if (bb == NULL)
+ return;
+
+ switch (ob->rigidbody_object->shape) {
+ case RB_SHAPE_BOX:
+ size[0] = 0.5f * fabsf(bb->vec[0][0] - bb->vec[4][0]);
+ size[1] = 0.5f * fabsf(bb->vec[0][1] - bb->vec[2][1]);
+ size[2] = 0.5f * fabsf(bb->vec[0][2] - bb->vec[1][2]);
+
+ vec[0][0] = vec[1][0] = vec[2][0] = vec[3][0] = -size[0];
+ vec[4][0] = vec[5][0] = vec[6][0] = vec[7][0] = +size[0];
+ vec[0][1] = vec[1][1] = vec[4][1] = vec[5][1] = -size[1];
+ vec[2][1] = vec[3][1] = vec[6][1] = vec[7][1] = +size[1];
+ vec[0][2] = vec[3][2] = vec[4][2] = vec[7][2] = -size[2];
+ vec[1][2] = vec[2][2] = vec[5][2] = vec[6][2] = +size[2];
+
+ draw_box(vec);
+ break;
+ case RB_SHAPE_SPHERE:
+ draw_bb_quadric(bb, OB_BOUND_SPHERE, true);
+ break;
+ case RB_SHAPE_CONE:
+ draw_bb_quadric(bb, OB_BOUND_CONE, true);
+ break;
+ case RB_SHAPE_CYLINDER:
+ draw_bb_quadric(bb, OB_BOUND_CYLINDER, true);
+ break;
+ case RB_SHAPE_CAPSULE:
+ draw_bb_quadric(bb, OB_BOUND_CAPSULE, true);
+ break;
+ }
+}
+
/**
* main object drawing function, draws in selection
* \param dflag (draw flag) can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET
@@ -7129,6 +7202,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
setlinestyle(0);
}
}
+ if (ob->rigidbody_object) {
+ draw_rigidbody_shape(ob);
+ }
/* draw extra: after normal draw because of makeDispList */
if (dtx && (G.f & G_RENDER_OGL) == 0) {
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 2e98058639b..dcbcb127f5c 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1543,7 +1543,7 @@ static int game_engine_exec(bContext *C, wmOperator *op)
//XXX restore_all_scene_cfra(scene_cfra_store);
BKE_scene_set_background(CTX_data_main(C), startscene);
- //XXX BKE_scene_update_for_newframe_viewport(bmain, scene, scene->lay);
+ //XXX BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, scene->lay);
BLI_callback_exec(bmain, &startscene->id, BLI_CB_EVT_GAME_POST);
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index e6e46c569e9..4bd4db9849b 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -6382,6 +6382,10 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t)
/* count */
t->total = 0;
+ if ((sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) == 0) {
+ return;
+ }
+
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c
index ff65e11f53e..e8146c34f5e 100644
--- a/source/blender/editors/util/crazyspace.c
+++ b/source/blender/editors/util/crazyspace.c
@@ -344,7 +344,7 @@ int sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**deformma
if (mti->type == eModifierTypeType_OnlyDeform) {
if (!defmats) {
Mesh *me = (Mesh *)ob->data;
- dm = mesh_create_derived(me, ob, NULL);
+ dm = mesh_create_derived(me, NULL);
deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
defmats = MEM_callocN(sizeof(*defmats) * numVerts, "defmats");
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index cc8a453c169..6ca3e1ae2a9 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -1318,13 +1318,11 @@ static void display_buffer_init_handle(void *handle_v, int start_line, int tot_l
handle->float_colorspace = init_data->float_colorspace;
}
-static void display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle, int start_scanline, int num_scanlines,
+static void display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle, int height,
float *linear_buffer, bool *is_straight_alpha)
{
int channels = handle->channels;
int width = handle->width;
- int height = num_scanlines;
- int scanline_offset = channels * start_scanline * width;
int buffer_size = channels * width * height;
@@ -1342,7 +1340,7 @@ static void display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle,
int i;
/* first convert byte buffer to float, keep in image space */
- for (i = 0, fp = linear_buffer, cp = byte_buffer + scanline_offset;
+ for (i = 0, fp = linear_buffer, cp = byte_buffer;
i < width * height;
i++, fp += channels, cp += channels)
{
@@ -1375,7 +1373,7 @@ static void display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle,
const char *from_colorspace = handle->float_colorspace;
const char *to_colorspace = global_role_scene_linear;
- memcpy(linear_buffer, handle->buffer + scanline_offset, buffer_size * sizeof(float));
+ memcpy(linear_buffer, handle->buffer, buffer_size * sizeof(float));
if (!is_data && !is_data_display) {
IMB_colormanagement_transform(linear_buffer, width, height, channels,
@@ -1391,7 +1389,7 @@ static void display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle,
* using duplicated buffer here
*/
- memcpy(linear_buffer, handle->buffer + scanline_offset, buffer_size * sizeof(float));
+ memcpy(linear_buffer, handle->buffer, buffer_size * sizeof(float));
*is_straight_alpha = false;
}
@@ -1421,69 +1419,50 @@ static void *do_display_buffer_apply_thread(void *handle_v)
}
}
else {
-#define SCANLINE_BLOCK_SIZE 64
- /* TODO(sergey): Instead of nasty scanline-blocking in per-scanline-block thread we might
- * better to use generic task scheduler, but that would need extra testing
- * before deploying into production.
- */
-
- int scanlines = (height + SCANLINE_BLOCK_SIZE - 1) / SCANLINE_BLOCK_SIZE;
- int i;
- float *linear_buffer = MEM_mallocN(channels * width * SCANLINE_BLOCK_SIZE * sizeof(float),
+ bool is_straight_alpha, predivide;
+ float *linear_buffer = MEM_mallocN(channels * width * height * sizeof(float),
"color conversion linear buffer");
- for (i = 0; i < scanlines; i ++) {
- int start_scanline = i * SCANLINE_BLOCK_SIZE;
- int num_scanlines = (i == scanlines - 1) ?
- (height - SCANLINE_BLOCK_SIZE * i) :
- SCANLINE_BLOCK_SIZE;
- int scanline_offset = channels * start_scanline * width;
- int scanline_offset4 = 4 * start_scanline * width;
- bool is_straight_alpha, predivide;
-
- display_buffer_apply_get_linear_buffer(handle, start_scanline, num_scanlines,
- linear_buffer, &is_straight_alpha);
- predivide = is_straight_alpha == false;
-
- if (is_data) {
- /* special case for data buffers - no color space conversions,
- * only generate byte buffers
- */
- }
- else {
- /* apply processor */
- IMB_colormanagement_processor_apply(cm_processor, linear_buffer, width, num_scanlines, channels,
- predivide);
- }
+ display_buffer_apply_get_linear_buffer(handle, height, linear_buffer, &is_straight_alpha);
- /* copy result to output buffers */
- if (display_buffer_byte) {
- /* do conversion */
- IMB_buffer_byte_from_float(display_buffer_byte + scanline_offset4, linear_buffer,
- channels, dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB,
- predivide, width, num_scanlines, width, width);
- }
+ predivide = is_straight_alpha == false;
+
+ if (is_data) {
+ /* special case for data buffers - no color space conversions,
+ * only generate byte buffers
+ */
+ }
+ else {
+ /* apply processor */
+ IMB_colormanagement_processor_apply(cm_processor, linear_buffer, width, height, channels,
+ predivide);
+ }
- if (display_buffer) {
- memcpy(display_buffer + scanline_offset, linear_buffer, width * num_scanlines * channels * sizeof(float));
+ /* copy result to output buffers */
+ if (display_buffer_byte) {
+ /* do conversion */
+ IMB_buffer_byte_from_float(display_buffer_byte, linear_buffer,
+ channels, dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB,
+ predivide, width, height, width, width);
+ }
- if (is_straight_alpha && channels == 4) {
- int i;
- float *fp;
+ if (display_buffer) {
+ memcpy(display_buffer, linear_buffer, width * height * channels * sizeof(float));
- for (i = 0, fp = display_buffer;
- i < width * num_scanlines;
- i++, fp += channels)
- {
- straight_to_premul_v4(fp);
- }
+ if (is_straight_alpha && channels == 4) {
+ int i;
+ float *fp;
+
+ for (i = 0, fp = display_buffer;
+ i < width * height;
+ i++, fp += channels)
+ {
+ straight_to_premul_v4(fp);
}
}
}
MEM_freeN(linear_buffer);
-
-#undef SCANLINE_BLOCK_SIZE
}
return NULL;
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index 71d5f5150ad..e0a6e034f94 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -41,7 +41,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-#include "BLI_threads.h"
+#include "BLI_task.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
@@ -288,48 +288,54 @@ void nearest_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, in
/*********************** Threaded image processing *************************/
+static void processor_apply_func(TaskPool *pool, void *taskdata, int UNUSED(threadid))
+{
+ void (*do_thread) (void *) = (void (*) (void *)) BLI_task_pool_userdata(pool);
+ do_thread(taskdata);
+}
+
void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_customdata,
void (init_handle) (void *handle, int start_line, int tot_line,
void *customdata),
void *(do_thread) (void *))
{
- void *handles;
- ListBase threads;
+ const int lines_per_task = 64;
+
+ TaskScheduler *task_scheduler = BLI_task_scheduler_get();
+ TaskPool *task_pool;
- int i, tot_thread = BLI_system_thread_count();
- int start_line, tot_line;
+ void *handles;
+ int total_tasks = (buffer_lines + lines_per_task - 1) / lines_per_task;
+ int i, start_line;
- handles = MEM_callocN(handle_size * tot_thread, "processor apply threaded handles");
+ task_pool = BLI_task_pool_create(task_scheduler, do_thread);
- if (tot_thread > 1)
- BLI_init_threads(&threads, do_thread, tot_thread);
+ handles = MEM_callocN(handle_size * total_tasks, "processor apply threaded handles");
start_line = 0;
- tot_line = ((float)(buffer_lines / tot_thread)) + 0.5f;
- for (i = 0; i < tot_thread; i++) {
- int cur_tot_line;
+ for (i = 0; i < total_tasks; i++) {
+ int lines_per_current_task;
void *handle = ((char *) handles) + handle_size * i;
- if (i < tot_thread - 1)
- cur_tot_line = tot_line;
+ if (i < total_tasks - 1)
+ lines_per_current_task = lines_per_task;
else
- cur_tot_line = buffer_lines - start_line;
+ lines_per_current_task = buffer_lines - start_line;
- init_handle(handle, start_line, cur_tot_line, init_customdata);
+ init_handle(handle, start_line, lines_per_current_task, init_customdata);
- if (tot_thread > 1)
- BLI_insert_thread(&threads, handle);
+ BLI_task_pool_push(task_pool, processor_apply_func, handle, false, TASK_PRIORITY_LOW);
- start_line += tot_line;
+ start_line += lines_per_task;
}
- if (tot_thread > 1)
- BLI_end_threads(&threads);
- else
- do_thread(handles);
+ /* work and wait until tasks are done */
+ BLI_task_pool_work_and_wait(task_pool);
+ /* Free memory. */
MEM_freeN(handles);
+ BLI_task_pool_free(task_pool);
}
/* Alpha-under */
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index 4a96c324f04..5d76ffe57b5 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -103,7 +103,8 @@ typedef struct RigidBodyOb {
int flag; /* (eRigidBodyOb_Flag) */
int col_groups; /* Collision groups that determines wich rigid bodies can collide with each other */
- int pad;
+ short mesh_source; /* (eRigidBody_MeshSource) mesh source for mesh based collision shapes */
+ short pad;
/* Physics Parameters */
float mass; /* how much object 'weighs' (i.e. absolute 'amount of stuff' it holds) */
@@ -148,7 +149,9 @@ typedef enum eRigidBodyOb_Flag {
/* rigidbody is not dynamically simulated */
RBO_FLAG_DISABLED = (1 << 5),
/* collision margin is not embedded (only used by convex hull shapes for now) */
- RBO_FLAG_USE_MARGIN = (1 << 6)
+ RBO_FLAG_USE_MARGIN = (1 << 6),
+ /* collision shape deforms during simulation (only for passive triangle mesh shapes) */
+ RBO_FLAG_USE_DEFORM = (1 << 7)
} eRigidBodyOb_Flag;
/* RigidBody Collision Shape */
@@ -173,6 +176,15 @@ typedef enum eRigidBody_Shape {
//RB_SHAPE_COMPOUND,
} eRigidBody_Shape;
+typedef enum eRigidBody_MeshSource {
+ /* base mesh */
+ RBO_MESH_BASE = 0,
+ /* only deformations */
+ RBO_MESH_DEFORM,
+ /* final derived mesh */
+ RBO_MESH_FINAL
+} eRigidBody_MeshSource;
+
/* ******************************** */
/* RigidBody Constraint */
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 9038885f6af..f2dc4dce11f 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -1107,27 +1107,28 @@ typedef struct SpaceClip {
/* SpaceClip->flag */
typedef enum eSpaceClip_Flag {
- SC_SHOW_MARKER_PATTERN = (1 << 0),
- SC_SHOW_MARKER_SEARCH = (1 << 1),
- SC_LOCK_SELECTION = (1 << 2),
- SC_SHOW_TINY_MARKER = (1 << 3),
- SC_SHOW_TRACK_PATH = (1 << 4),
- SC_SHOW_BUNDLES = (1 << 5),
- SC_MUTE_FOOTAGE = (1 << 6),
- SC_HIDE_DISABLED = (1 << 7),
- SC_SHOW_NAMES = (1 << 8),
- SC_SHOW_GRID = (1 << 9),
- SC_SHOW_STABLE = (1 << 10),
- SC_MANUAL_CALIBRATION = (1 << 11),
- SC_SHOW_GPENCIL = (1 << 12),
- SC_SHOW_FILTERS = (1 << 13),
- SC_SHOW_GRAPH_FRAMES = (1 << 14),
- SC_SHOW_GRAPH_TRACKS = (1 << 15),
-/* SC_SHOW_PYRAMID_LEVELS = (1 << 16), */ /* UNUSED */
- SC_LOCK_TIMECURSOR = (1 << 17),
- SC_SHOW_SECONDS = (1 << 18),
- SC_SHOW_GRAPH_SEL_ONLY = (1 << 19),
- SC_SHOW_GRAPH_HIDDEN = (1 << 20),
+ SC_SHOW_MARKER_PATTERN = (1 << 0),
+ SC_SHOW_MARKER_SEARCH = (1 << 1),
+ SC_LOCK_SELECTION = (1 << 2),
+ SC_SHOW_TINY_MARKER = (1 << 3),
+ SC_SHOW_TRACK_PATH = (1 << 4),
+ SC_SHOW_BUNDLES = (1 << 5),
+ SC_MUTE_FOOTAGE = (1 << 6),
+ SC_HIDE_DISABLED = (1 << 7),
+ SC_SHOW_NAMES = (1 << 8),
+ SC_SHOW_GRID = (1 << 9),
+ SC_SHOW_STABLE = (1 << 10),
+ SC_MANUAL_CALIBRATION = (1 << 11),
+ SC_SHOW_GPENCIL = (1 << 12),
+ SC_SHOW_FILTERS = (1 << 13),
+ SC_SHOW_GRAPH_FRAMES = (1 << 14),
+ SC_SHOW_GRAPH_TRACKS_MOTION = (1 << 15),
+/* SC_SHOW_PYRAMID_LEVELS = (1 << 16), */ /* UNUSED */
+ SC_LOCK_TIMECURSOR = (1 << 17),
+ SC_SHOW_SECONDS = (1 << 18),
+ SC_SHOW_GRAPH_SEL_ONLY = (1 << 19),
+ SC_SHOW_GRAPH_HIDDEN = (1 << 20),
+ SC_SHOW_GRAPH_TRACKS_ERROR = (1 << 21),
} eSpaceClip_Flag;
/* SpaceClip->mode */
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 35be44c4090..1710f9e81af 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -969,7 +969,7 @@ static int make_structDNA(const char *baseDirectory, FILE *file)
names = MEM_callocN(sizeof(char *) * maxnr, "names");
types = MEM_callocN(sizeof(char *) * maxnr, "types");
typelens_native = MEM_callocN(sizeof(short) * maxnr, "typelens_native");
- typelens_32 = MEM_callocN(sizeof(short) * maxnr, "typelens_64");
+ typelens_32 = MEM_callocN(sizeof(short) * maxnr, "typelens_32");
typelens_64 = MEM_callocN(sizeof(short) * maxnr, "typelens_64");
structs = MEM_callocN(sizeof(short *) * maxnr, "structs");
@@ -981,7 +981,7 @@ static int make_structDNA(const char *baseDirectory, FILE *file)
add_type("short", 2); /* SDNA_TYPE_SHORT */
add_type("ushort", 2); /* SDNA_TYPE_USHORT */
add_type("int", 4); /* SDNA_TYPE_INT */
- add_type("long", 4); /* SDNA_TYPE_LONG */ /* should it be 8 on 64 bits? */
+ add_type("long", 4); /* SDNA_TYPE_LONG */ /* maybe 4 or 8 bytes depending on platform, disallowed for now */
add_type("ulong", 4); /* SDNA_TYPE_ULONG */
add_type("float", 4); /* SDNA_TYPE_FLOAT */
add_type("double", 8); /* SDNA_TYPE_DOUBLE */
diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c
index 6a43fed3ac6..b7b793ebeaf 100644
--- a/source/blender/makesrna/intern/rna_main.c
+++ b/source/blender/makesrna/intern/rna_main.c
@@ -42,6 +42,22 @@
/* all the list begin functions are added manually here, Main is not in SDNA */
+static int rna_Main_use_autopack_get(PointerRNA *UNUSED(ptr))
+{
+ if (G.fileflags & G_AUTOPACK)
+ return 1;
+
+ return 0;
+}
+
+static void rna_Main_use_autopack_set(PointerRNA *UNUSED(ptr), int value)
+{
+ if (value)
+ G.fileflags |= G_AUTOPACK;
+ else
+ G.fileflags &= ~G_AUTOPACK;
+}
+
static int rna_Main_is_saved_get(PointerRNA *UNUSED(ptr))
{
return G.relbase_valid;
@@ -356,6 +372,10 @@ void RNA_def_main(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, "rna_Main_is_saved_get", NULL);
RNA_def_property_ui_text(prop, "File is Saved", "Has the current session been saved to disk as a .blend file");
+ prop = RNA_def_property(srna, "use_autopack", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_Main_use_autopack_get", "rna_Main_use_autopack_set");
+ RNA_def_property_ui_text(prop, "Use Autopack", "Automatically pack all external data into .blend file");
+
for (i = 0; lists[i].name; i++) {
prop = RNA_def_property(srna, lists[i].identifier, PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, lists[i].type);
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 84ee2b1402e..de002bdfd2c 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -80,7 +80,7 @@ EnumPropertyItem modifier_type_items[] = {
{eModifierType_Solidify, "SOLIDIFY", ICON_MOD_SOLIDIFY, "Solidify", ""},
{eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""},
{eModifierType_Triangulate, "TRIANGULATE", ICON_MOD_TRIANGULATE, "Triangulate", ""},
- {eModifierType_Wireframe, "WIREFRAME", ICON_MOD_WIREFRAME, "Wireframe", "Generates a wireframe on the edges of a mesh"},
+ {eModifierType_Wireframe, "WIREFRAME", ICON_MOD_WIREFRAME, "Wireframe", "Generate a wireframe on the edges of a mesh"},
{0, "", 0, N_("Deform"), ""},
{eModifierType_Armature, "ARMATURE", ICON_MOD_ARMATURE, "Armature", ""},
{eModifierType_Cast, "CAST", ICON_MOD_CAST, "Cast", ""},
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 8cd3252fe10..85e0d91fc71 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -386,7 +386,7 @@ void rna_Object_dm_info(struct Object *ob, int type, char *result)
switch (type) {
case 0:
if (ob->type == OB_MESH) {
- dm = CDDM_from_mesh(ob->data, ob);
+ dm = CDDM_from_mesh(ob->data);
ret = DM_debug_info(dm);
dm_release = TRUE;
}
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index cc14e60f45a..58fc9ab25d4 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -76,6 +76,13 @@ EnumPropertyItem rigidbody_constraint_type_items[] = {
{RBC_TYPE_MOTOR, "MOTOR", ICON_NONE, "Motor", "Drive rigid body around or along an axis"},
{0, NULL, 0, NULL, NULL}};
+/* mesh source for collision shape creation */
+EnumPropertyItem rigidbody_mesh_source_items[] = {
+ {RBO_MESH_BASE, "BASE", 0, "Base", "Base mesh"},
+ {RBO_MESH_DEFORM, "DEFORM", 0, "Deform", "Deformations (shaps keys, deform modifiers"},
+ {RBO_MESH_FINAL, "FINAL", 0, "Final", "All modifiers"},
+ {0, NULL, 0, NULL, NULL}};
+
#ifdef RNA_RUNTIME
@@ -769,6 +776,13 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
+ prop = RNA_def_property(srna, "mesh_source", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "mesh_source");
+ RNA_def_property_enum_items(prop, rigidbody_mesh_source_items);
+ RNA_def_property_ui_text(prop, "Mesh Source", "Source of the mesh used to create collision shape");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
+
/* booleans */
prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", RBO_FLAG_DISABLED);
@@ -790,6 +804,11 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Kinematic", "Allow rigid body to be controlled by the animation system");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
+ prop = RNA_def_property(srna, "use_deform", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_USE_DEFORM);
+ RNA_def_property_ui_text(prop, "Deforming", "Rigid body deforms during simulation");
+ RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
+
/* Physics Parameters */
prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS);
RNA_def_property_float_sdna(prop, NULL, "mass");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index fdaf204be23..ae6b2e75658 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3745,14 +3745,21 @@ static void rna_def_space_clip(BlenderRNA *brna)
"Show curve for per-frame average error (camera motion should be solved first)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
- /* show graph_tracks */
- prop = RNA_def_property(srna, "show_graph_tracks", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GRAPH_TRACKS);
- RNA_def_property_ui_text(prop, "Show Tracks",
+ /* show graph tracks motion */
+ prop = RNA_def_property(srna, "show_graph_tracks_motion", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GRAPH_TRACKS_MOTION);
+ RNA_def_property_ui_text(prop, "Show Tracks Motion",
"Display the speed curves (in \"x\" direction red, in \"y\" direction green) "
"for the selected tracks");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
+ /* show graph tracks motion */
+ prop = RNA_def_property(srna, "show_graph_tracks_error", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GRAPH_TRACKS_ERROR);
+ RNA_def_property_ui_text(prop, "Show Tracks Error",
+ "Display the reprojection error curve for selected tracks");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
+
/* show_only_selected */
prop = RNA_def_property(srna, "show_graph_only_selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GRAPH_SEL_ONLY);
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index 3ab7bff0e63..e81fc44f238 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -179,7 +179,7 @@ static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedDat
ArmatureModifierData *amd = (ArmatureModifierData *) md;
DerivedMesh *dm = derivedData;
- if (!derivedData) dm = CDDM_from_mesh((Mesh *)ob->data, ob);
+ if (!derivedData) dm = CDDM_from_mesh((Mesh *)ob->data);
armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts,
amd->deformflag, NULL, amd->defgrp_name);
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index 9335d7577c7..1f24662960a 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -116,7 +116,7 @@ static void deformVerts(ModifierData *md, Object *ob,
/* if possible use/create DerivedMesh */
if (derivedData) dm = CDDM_copy(derivedData);
- else if (ob->type == OB_MESH) dm = CDDM_from_mesh(ob->data, ob);
+ else if (ob->type == OB_MESH) dm = CDDM_from_mesh(ob->data);
if (!ob->pd) {
printf("CollisionModifier deformVerts: Should not happen!\n");
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index e754ac8f766..1d5dc29c119 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -96,14 +96,15 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
}
static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+ DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
MaskModifierData *mmd = (MaskModifierData *)md;
- DerivedMesh *dm = derivedData, *result = NULL;
+ const bool found_test = (mmd->flag & MOD_MASK_INV) == 0;
+ DerivedMesh *result = NULL;
GHash *vertHash = NULL, *edgeHash, *polyHash;
GHashIterator *hashIter;
- MDeformVert *dvert = NULL, *dv;
+ MDeformVert *dvert, *dv;
int numPolys = 0, numLoops = 0, numEdges = 0, numVerts = 0;
int maxVerts, maxEdges, maxPolys;
int i;
@@ -119,6 +120,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
int *loop_mapping;
+ dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
+ if (dvert == NULL) {
+ return found_test ? CDDM_from_template(dm, 0, 0, 0, 0, 0) : dm;
+ }
+
/* Overview of Method:
* 1. Get the vertices that are in the vertexgroup of interest
* 2. Filter out unwanted geometry (i.e. not in vertexgroup), by populating mappings with new vs old indices
@@ -136,7 +142,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
if (!(ELEM(mmd->mode, MOD_MASK_MODE_ARM, MOD_MASK_MODE_VGROUP)) ||
(maxVerts == 0) || (ob->defbase.first == NULL) )
{
- return derivedData;
+ return dm;
}
/* if mode is to use selected armature bones, aggregate the bone groups */
@@ -150,7 +156,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* check that there is armature object with bones to use, otherwise return original mesh */
if (ELEM3(NULL, oba, oba->pose, ob->defbase.first))
- return derivedData;
+ return dm;
/* determine whether each vertexgroup is associated with a selected bone or not
* - each cell is a boolean saying whether bone corresponding to the ith group is selected
@@ -168,16 +174,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
bone_select_array[i] = FALSE;
}
}
-
- /* if no dverts (i.e. no data for vertex groups exists), we've got an
- * inconsistent situation, so free hashes and return original mesh
- */
- dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
- if (dvert == NULL) {
- MEM_freeN(bone_select_array);
- return derivedData;
- }
-
+
/* verthash gives mapping from original vertex indices to the new indices (including selected matches only)
* key = oldindex, value = newindex
*/
@@ -189,7 +186,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
*/
for (i = 0, dv = dvert; i < maxVerts; i++, dv++) {
MDeformWeight *dw = dv->dw;
- short found = 0;
+ bool found = false;
int j;
/* check the groups that vertex is assigned to, and see if it was any use */
@@ -204,14 +201,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
}
- /* check if include vert in vertHash */
- if (mmd->flag & MOD_MASK_INV) {
- /* if this vert is in the vgroup, don't include it in vertHash */
- if (found) continue;
- }
- else {
- /* if this vert isn't in the vgroup, don't include it in vertHash */
- if (!found) continue;
+ if (found_test != found) {
+ continue;
}
/* add to ghash for verts (numVerts acts as counter for mapping) */
@@ -224,13 +215,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
else { /* --- Using Nominated VertexGroup only --- */
int defgrp_index = defgroup_name_index(ob, mmd->vgroup);
-
- /* get dverts */
- if (defgrp_index != -1)
- dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
-
+
/* if no vgroup (i.e. dverts) found, return the initial mesh */
- if ((defgrp_index == -1) || (dvert == NULL))
+ if (defgrp_index == -1)
return dm;
/* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */
@@ -238,18 +225,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* add vertices which exist in vertexgroup into ghash for filtering */
for (i = 0, dv = dvert; i < maxVerts; i++, dv++) {
- const int weight_set = defvert_find_weight(dv, defgrp_index) != 0.0f;
-
- /* check if include vert in vertHash */
- if (mmd->flag & MOD_MASK_INV) {
- /* if this vert is in the vgroup, don't include it in vertHash */
- if (weight_set) continue;
+ const bool found = defvert_find_weight(dv, defgrp_index) != 0.0f;
+ if (found_test != found) {
+ continue;
}
- else {
- /* if this vert isn't in the vgroup, don't include it in vertHash */
- if (!weight_set) continue;
- }
-
+
/* add to ghash for verts (numVerts acts as counter for mapping) */
BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(i), SET_INT_IN_POINTER(numVerts));
numVerts++;
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 0c3746fc570..c087a7870c0 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -183,7 +183,7 @@ DerivedMesh *get_dm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm,
}
else if (ob->type == OB_MESH) {
if (em) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
- else dm = CDDM_from_mesh((struct Mesh *)(ob->data), ob);
+ else dm = CDDM_from_mesh((struct Mesh *)(ob->data));
if (vertexCos) {
CDDM_apply_vert_coords(dm, vertexCos);
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 06f4664c11b..ecb99974472 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -473,7 +473,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
if (me->edit_btmesh)
target_dm = CDDM_from_editbmesh(me->edit_btmesh, FALSE, FALSE);
else
- target_dm = CDDM_from_mesh(me, obr);
+ target_dm = CDDM_from_mesh(me);
}
free_target_dm = TRUE;
}
diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c
index af228ca5f57..3ebd9bd38fd 100644
--- a/source/blender/modifiers/intern/MOD_wireframe.c
+++ b/source/blender/modifiers/intern/MOD_wireframe.c
@@ -75,7 +75,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
}
-static DerivedMesh* WireframeModifier_do( WireframeModifierData *wmd, Object *ob, DerivedMesh *dm)
+static DerivedMesh *WireframeModifier_do( WireframeModifierData *wmd, Object *ob, DerivedMesh *dm)
{
DerivedMesh *result;
BMesh *bm;
diff --git a/source/blender/python/bmesh/bmesh_py_utils.c b/source/blender/python/bmesh/bmesh_py_utils.c
index d228e1a0646..236d6badd55 100644
--- a/source/blender/python/bmesh/bmesh_py_utils.c
+++ b/source/blender/python/bmesh/bmesh_py_utils.c
@@ -401,6 +401,7 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args,
BMesh *bm;
BMFace *f_new = NULL;
BMLoop *l_new = NULL;
+ BMLoop *l_a, *l_b;
if (!PyArg_ParseTupleAndKeywords(args, kw, "O!O!O!|OiO!:face_split", (char **)kwlist,
&BPy_BMFace_Type, &py_face,
@@ -422,9 +423,12 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args,
}
/* this doubles for checking that the verts are in the same mesh */
- if (BM_vert_in_face(py_face->f, py_vert_a->v) == false ||
- BM_vert_in_face(py_face->f, py_vert_b->v) == false)
+ if ((l_a = BM_face_vert_share_loop(py_face->f, py_vert_a->v)) &&
+ (l_b = BM_face_vert_share_loop(py_face->f, py_vert_b->v)))
{
+ /* pass */
+ }
+ else {
PyErr_SetString(PyExc_ValueError,
"face_split(...): one of the verts passed is not found in the face");
return NULL;
@@ -448,14 +452,14 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args,
if (ncoords) {
f_new = BM_face_split_n(bm, py_face->f,
- py_vert_a->v, py_vert_b->v,
+ l_a, l_b,
(float (*)[3])coords, ncoords,
&l_new, py_edge_example ? py_edge_example->e : NULL);
PyMem_Free(coords);
}
else {
f_new = BM_face_split(bm, py_face->f,
- py_vert_a->v, py_vert_b->v,
+ l_a, l_b,
&l_new, py_edge_example ? py_edge_example->e : NULL, edge_exists);
}
diff --git a/source/blender/python/generic/bpy_threads.c b/source/blender/python/generic/bpy_threads.c
index 610c1846f56..63a47ff0b20 100644
--- a/source/blender/python/generic/bpy_threads.c
+++ b/source/blender/python/generic/bpy_threads.c
@@ -27,14 +27,6 @@
* these functions are slightly different from the original Python API,
* don't throw SIGABRT even if the thread state is NULL. */
-/** \file blender/python/intern/bpy_interface.c
- * \ingroup pythonintern
- *
- * This file deals with embedding the python interpreter within blender,
- * starting and stopping python and exposing blender/python modules so they can
- * be accesses from scripts.
- */
-
/* grr, python redefines */
#ifdef _POSIX_C_SOURCE
# undef _POSIX_C_SOURCE
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index afff90feb49..78434427b18 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -1612,6 +1612,7 @@ static bool rlayer_node_uses_alpha(bNodeTree *ntree, bNode *node)
*/
#define DEPSGRAPH_WORKAROUND_HACK
+#ifdef DEPSGRAPH_WORKAROUND_HACK
static bool allow_render_mesh_object(Object *ob)
{
/* override not showing object when duplis are used with particles */
@@ -1625,7 +1626,6 @@ static bool allow_render_mesh_object(Object *ob)
return true;
}
-#ifdef DEPSGRAPH_WORKAROUND_HACK
static void tag_dependend_objects_for_render(Scene *scene, int renderlay)
{
Scene *sce_iter;
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 9998f10e417..9dfad5bc0ed 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -941,15 +941,16 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene,
// Without checking names, we get some reuse we don't want that can cause
// problems with material LoDs.
- if ((meshobj = converter->FindGameMesh(mesh/*, ob->lay*/)) != NULL) {
- STR_String bge_name = meshobj->GetName();
- STR_String blender_name = ((Mesh*)blenderobj->data)->id.name+2;
- if (bge_name == blender_name)
+ if (blenderobj && ((meshobj = converter->FindGameMesh(mesh/*, ob->lay*/)) != NULL)) {
+ const char *bge_name = meshobj->GetName().ReadPtr();
+ const char *blender_name = ((ID *)blenderobj->data)->name + 2;
+ if (STREQ(bge_name, blender_name)) {
return meshobj;
+ }
}
// Get DerivedMesh data
- DerivedMesh *dm = CDDM_from_mesh(mesh, blenderobj);
+ DerivedMesh *dm = CDDM_from_mesh(mesh);
DM_ensure_tessface(dm);
MVert *mvert = dm->getVertArray(dm);
diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp
index f1f264b3367..be85d89775f 100644
--- a/source/gameengine/Converter/BlenderWorldInfo.cpp
+++ b/source/gameengine/Converter/BlenderWorldInfo.cpp
@@ -64,22 +64,19 @@
/* end of blender include block */
-BlenderWorldInfo::BlenderWorldInfo(struct Scene *blenderscene, struct World* blenderworld)
+BlenderWorldInfo::BlenderWorldInfo(struct Scene *blenderscene, struct World *blenderworld)
{
- if (blenderworld)
- {
+ if (blenderworld) {
m_hasworld = true;
// do we have mist?
- if ((blenderworld->mode) & WO_MIST)
- {
+ if ((blenderworld->mode) & WO_MIST) {
m_hasmist = true;
m_miststart = blenderworld->miststa;
m_mistdistance = blenderworld->mistdist;
copy_v3_v3(m_mistcolor, &blenderworld->horr);
}
- else
- {
+ else {
m_hasmist = false;
m_miststart = 0.0;
m_mistdistance = 0.0;
@@ -95,53 +92,39 @@ BlenderWorldInfo::BlenderWorldInfo(struct Scene *blenderscene, struct World* ble
linearrgb_to_srgb_v3_v3(m_ambientcolor, m_ambientcolor);
}
}
- else
- {
+ else {
m_hasworld = false;
}
}
-
-
BlenderWorldInfo::~BlenderWorldInfo()
{
-
}
-
bool BlenderWorldInfo::hasWorld()
{
return m_hasworld;
}
-
-
bool BlenderWorldInfo::hasMist()
{
return m_hasmist;
}
-
-
float BlenderWorldInfo::getBackColorRed()
{
return m_backgroundcolor[0];
}
-
-
float BlenderWorldInfo::getBackColorGreen()
{
return m_backgroundcolor[1];
-}
-
-
+}
float BlenderWorldInfo::getBackColorBlue()
{
return m_backgroundcolor[2];
-}
-
+}
float BlenderWorldInfo::getAmbientColorRed()
{
@@ -163,28 +146,20 @@ float BlenderWorldInfo::getMistStart()
return m_miststart;
}
-
-
float BlenderWorldInfo::getMistDistance()
{
return m_mistdistance;
}
-
-
float BlenderWorldInfo::getMistColorRed()
{
return m_mistcolor[0];
}
-
-
float BlenderWorldInfo::getMistColorGreen()
{
return m_mistcolor[1];
-}
-
-
+}
float BlenderWorldInfo::getMistColorBlue()
{
@@ -198,41 +173,27 @@ void BlenderWorldInfo::setBackColor(float r, float g, float b)
m_backgroundcolor[2] = b;
}
- void
-BlenderWorldInfo::setMistStart(
- float d
-) {
+void BlenderWorldInfo::setMistStart(float d)
+{
m_miststart = d;
}
-
- void
-BlenderWorldInfo::setMistDistance(
- float d
-) {
+void BlenderWorldInfo::setMistDistance(float d)
+{
m_mistdistance = d;
}
-
- void
-BlenderWorldInfo::setMistColorRed(
- float d
-) {
+void BlenderWorldInfo::setMistColorRed(float d)
+{
m_mistcolor[0] = d;
}
-
- void
-BlenderWorldInfo::setMistColorGreen(
- float d
-) {
+void BlenderWorldInfo::setMistColorGreen(float d)
+{
m_mistcolor[1] = d;
}
-
- void
-BlenderWorldInfo::setMistColorBlue(
- float d
-) {
+void BlenderWorldInfo::setMistColorBlue(float d)
+{
m_mistcolor[2] = d;
}
diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h
index af535d65d62..2ac2d70b5d1 100644
--- a/source/gameengine/Converter/BlenderWorldInfo.h
+++ b/source/gameengine/Converter/BlenderWorldInfo.h
@@ -36,68 +36,44 @@
class BlenderWorldInfo : public KX_WorldInfo
{
- bool m_hasworld;
- float m_backgroundcolor[3];
+ bool m_hasworld;
+ float m_backgroundcolor[3];
- bool m_hasmist;
- float m_miststart;
- float m_mistdistance;
- float m_mistcolor[3];
+ bool m_hasmist;
+ float m_miststart;
+ float m_mistdistance;
+ float m_mistcolor[3];
- float m_ambientcolor[3];
+ float m_ambientcolor[3];
public:
- BlenderWorldInfo(struct Scene *blenderscene, struct World* blenderworld);
+ BlenderWorldInfo(struct Scene *blenderscene, struct World *blenderworld);
~BlenderWorldInfo();
- bool hasWorld();
- bool hasMist();
- float getBackColorRed();
- float getBackColorGreen();
- float getBackColorBlue();
-
- float getAmbientColorRed();
- float getAmbientColorGreen();
- float getAmbientColorBlue();
+ bool hasWorld();
+ bool hasMist();
+ float getBackColorRed();
+ float getBackColorGreen();
+ float getBackColorBlue();
- float getMistStart();
- float getMistDistance();
- float getMistColorRed();
- float getMistColorGreen();
- float getMistColorBlue();
+ float getAmbientColorRed();
+ float getAmbientColorGreen();
+ float getAmbientColorBlue();
- void
- setBackColor(
- float r,
- float g,
- float b
- );
- void
- setMistStart(
- float d
- );
+ float getMistStart();
+ float getMistDistance();
+ float getMistColorRed();
+ float getMistColorGreen();
+ float getMistColorBlue();
- void
- setMistDistance(
- float d
- );
+ void setBackColor(float r, float g, float b);
+ void setMistStart(float d);
+ void setMistDistance(float d);
+ void setMistColorRed(float d);
+ void setMistColorGreen(float d);
+ void setMistColorBlue(float d);
- void
- setMistColorRed(
- float d
- );
- void
- setMistColorGreen(
- float d
- );
-
- void
- setMistColorBlue(
- float d
- );
-
-
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:BlenderWorldInfo")
#endif
diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h
index 859c31adcd3..719a74ee219 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.h
+++ b/source/gameengine/Ketsji/KX_PythonInit.h
@@ -34,32 +34,33 @@
#include "KX_Python.h"
#include "STR_String.h"
+#include "MT_Vector3.h"
typedef enum {
psl_Lowest = 0,
- psl_Highest
+ psl_Highest,
} TPythonSecurityLevel;
extern bool gUseVisibilityTemp;
#ifdef WITH_PYTHON
-PyObject* initGameLogic(class KX_KetsjiEngine *engine, class KX_Scene* ketsjiscene);
-PyObject* initGameKeys();
-PyObject* initRasterizer(class RAS_IRasterizer* rasty,class RAS_ICanvas* canvas);
-PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level, struct Main *maggie, int argc, char** argv);
-PyObject* initVideoTexture(void);
-void exitGamePlayerPythonScripting();
-PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level, struct Main *maggie);
-void exitGamePythonScripting();
-
+PyObject *initGameLogic(class KX_KetsjiEngine *engine, class KX_Scene *ketsjiscene);
+PyObject *initGameKeys();
+PyObject *initRasterizer(class RAS_IRasterizer *rasty,class RAS_ICanvas *canvas);
+PyObject *initGamePlayerPythonScripting(const STR_String &progname, TPythonSecurityLevel level,
+ struct Main *maggie, int argc, char **argv);
+PyObject *initVideoTexture(void);
+PyObject *initGamePythonScripting(const STR_String &progname, TPythonSecurityLevel level, struct Main *maggie);
+
+void exitGamePlayerPythonScripting();
+void exitGamePythonScripting();
void setupGamePython(KX_KetsjiEngine *ketsjiengine, KX_Scene *startscene, Main *blenderdata,
- PyObject *pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char** argv);
-
-void setGamePythonPath(const char *path);
-void resetGamePythonPath();
-void pathGamePythonConfig( char *path );
-int saveGamePythonConfig( char **marshal_buffer);
-int loadGamePythonConfig(char *marshal_buffer, int marshal_length);
+ PyObject *pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char **argv);
+void setGamePythonPath(const char *path);
+void resetGamePythonPath();
+void pathGamePythonConfig(char *path);
+int saveGamePythonConfig(char **marshal_buffer);
+int loadGamePythonConfig(char *marshal_buffer, int marshal_length);
#endif
void addImportMain(struct Main *maggie);
@@ -68,9 +69,9 @@ void removeImportMain(struct Main *maggie);
class KX_KetsjiEngine;
class KX_Scene;
-void KX_SetActiveScene(class KX_Scene* scene);
-class KX_Scene* KX_GetActiveScene();
-class KX_KetsjiEngine* KX_GetActiveEngine();
+void KX_SetActiveScene(class KX_Scene *scene);
+class KX_Scene *KX_GetActiveScene();
+class KX_KetsjiEngine *KX_GetActiveEngine();
typedef int (*PyNextFrameFunc)(void *);
@@ -82,11 +83,9 @@ struct PyNextFrameState {
};
extern struct PyNextFrameState pynextframestate;
-#include "MT_Vector3.h"
-
-void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color);
-void KX_RasterizerDrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color,
- const MT_Vector3& normal, int nsector);
+void KX_RasterizerDrawDebugLine(const MT_Vector3 &from,const MT_Vector3 &to,const MT_Vector3 &color);
+void KX_RasterizerDrawDebugCircle(const MT_Vector3 &center, const MT_Scalar radius, const MT_Vector3 &color,
+ const MT_Vector3 &normal, int nsector);
#endif /* __KX_PYTHONINIT_H__ */
diff --git a/source/gameengine/Ketsji/KX_WorldInfo.h b/source/gameengine/Ketsji/KX_WorldInfo.h
index a64ca5c191e..90b16fe1242 100644
--- a/source/gameengine/Ketsji/KX_WorldInfo.h
+++ b/source/gameengine/Ketsji/KX_WorldInfo.h
@@ -46,29 +46,29 @@ public:
KX_WorldInfo() {}
virtual ~KX_WorldInfo();
- virtual bool hasWorld()=0;
- virtual bool hasMist()=0;
- virtual float getBackColorRed()=0;
- virtual float getBackColorGreen()=0;
- virtual float getBackColorBlue()=0;
- virtual float getMistStart()=0;
- virtual float getMistDistance()=0;
- virtual float getMistColorRed()=0;
- virtual float getMistColorGreen()=0;
- virtual float getMistColorBlue()=0;
+ virtual bool hasWorld() = 0;
+ virtual bool hasMist() = 0;
+ virtual float getBackColorRed() = 0;
+ virtual float getBackColorGreen() = 0;
+ virtual float getBackColorBlue() = 0;
+ virtual float getMistStart() = 0;
+ virtual float getMistDistance() = 0;
+ virtual float getMistColorRed() = 0;
+ virtual float getMistColorGreen() = 0;
+ virtual float getMistColorBlue() = 0;
+
+ virtual float getAmbientColorRed() = 0;
+ virtual float getAmbientColorGreen() = 0;
+ virtual float getAmbientColorBlue() = 0;
+
+ virtual void setBackColor(float, float, float) = 0;
+ virtual void setMistStart(float) = 0;
+ virtual void setMistDistance(float) = 0;
+ virtual void setMistColorRed(float) = 0;
+ virtual void setMistColorGreen(float) = 0;
+ virtual void setMistColorBlue(float) = 0;
- virtual float getAmbientColorRed()=0;
- virtual float getAmbientColorGreen()=0;
- virtual float getAmbientColorBlue()=0;
- virtual void setBackColor(float,float,float)=0;
- virtual void setMistStart(float)=0;
- virtual void setMistDistance(float)=0;
- virtual void setMistColorRed(float)=0;
- virtual void setMistColorGreen(float)=0;
- virtual void setMistColorBlue(float)=0;
-
-
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_WorldInfo")
#endif
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index 6be6400e011..33726018268 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -1728,7 +1728,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm,
if (!dm) {
free_dm = true;
- dm = CDDM_from_mesh(meshobj->GetMesh(), NULL);
+ dm = CDDM_from_mesh(meshobj->GetMesh());
DM_ensure_tessface(dm);
}
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h
index 034ea7f87a9..f9369cf5e40 100644
--- a/source/gameengine/Rasterizer/RAS_IRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h
@@ -56,8 +56,8 @@ class RAS_MeshSlot;
typedef vector<unsigned short> KX_IndexArray;
typedef vector<RAS_TexVert> KX_VertexArray;
-typedef vector< KX_VertexArray* > vecVertexArray;
-typedef vector< KX_IndexArray* > vecIndexArrays;
+typedef vector<KX_VertexArray *> vecVertexArray;
+typedef vector<KX_IndexArray *> vecIndexArrays;
/**
* 3D rendering device context interface.
@@ -69,7 +69,7 @@ public:
RAS_TEXT_RENDER_NODEF = 0,
RAS_TEXT_NORMAL,
RAS_TEXT_PADDED,
- RAS_TEXT_MAX
+ RAS_TEXT_MAX,
};
RAS_IRasterizer(RAS_ICanvas* canv) {};
@@ -79,12 +79,12 @@ public:
* Drawing types
*/
enum DrawType {
- KX_BOUNDINGBOX = 1,
- KX_WIREFRAME,
- KX_SOLID,
- KX_SHADED,
- KX_TEXTURED,
- KX_SHADOW
+ KX_BOUNDINGBOX = 1,
+ KX_WIREFRAME,
+ KX_SOLID,
+ KX_SHADED,
+ KX_TEXTURED,
+ KX_SHADOW,
};
/**
@@ -94,67 +94,67 @@ public:
enum DrawMode {
KX_MODE_LINES = 1,
KX_MODE_TRIANGLES,
- KX_MODE_QUADS
+ KX_MODE_QUADS,
};
/**
* Valid SetDepthMask parameters
*/
enum DepthMask {
- KX_DEPTHMASK_ENABLED =1,
- KX_DEPTHMASK_DISABLED
+ KX_DEPTHMASK_ENABLED = 1,
+ KX_DEPTHMASK_DISABLED,
};
/**
*/
enum {
- RAS_RENDER_3DPOLYGON_TEXT = 64, /* GEMAT_TEXT */
- KX_BACKCULL = 16, /* GEMAT_BACKCULL */
- KX_TEX = 4096, /* GEMAT_TEX */
- KX_LINES = 32768
+ RAS_RENDER_3DPOLYGON_TEXT = 64, /* GEMAT_TEXT */
+ KX_BACKCULL = 16, /* GEMAT_BACKCULL */
+ KX_TEX = 4096, /* GEMAT_TEX */
+ KX_LINES = 32768,
};
/**
* Stereo mode types
*/
enum StereoMode {
- RAS_STEREO_NOSTEREO = 1,
- RAS_STEREO_QUADBUFFERED,
- RAS_STEREO_ABOVEBELOW,
- RAS_STEREO_INTERLACED,
- RAS_STEREO_ANAGLYPH,
- RAS_STEREO_SIDEBYSIDE,
- RAS_STEREO_VINTERLACE,
- RAS_STEREO_DOME,
-
- RAS_STEREO_MAXSTEREO
+ RAS_STEREO_NOSTEREO = 1,
+ RAS_STEREO_QUADBUFFERED,
+ RAS_STEREO_ABOVEBELOW,
+ RAS_STEREO_INTERLACED,
+ RAS_STEREO_ANAGLYPH,
+ RAS_STEREO_SIDEBYSIDE,
+ RAS_STEREO_VINTERLACE,
+ RAS_STEREO_DOME,
+
+ RAS_STEREO_MAXSTEREO
};
/**
* Texture gen modes.
*/
enum TexCoGen {
- RAS_TEXCO_GEN, //< GPU will generate texture coordinates
- RAS_TEXCO_ORCO, //< Vertex coordinates (object space)
- RAS_TEXCO_GLOB, //< Vertex coordinates (world space)
- RAS_TEXCO_UV, //< UV coordinates
- RAS_TEXCO_OBJECT, //< Use another object's position as coordinates
- RAS_TEXCO_LAVECTOR, //< Light vector as coordinates
- RAS_TEXCO_VIEW, //< View vector as coordinates
- RAS_TEXCO_STICKY, //< Sticky coordinates
- RAS_TEXCO_WINDOW, //< Window coordinates
- RAS_TEXCO_NORM, //< Normal coordinates
- RAS_TEXTANGENT, //<
- RAS_TEXCO_VCOL, //< Vertex Color
- RAS_TEXCO_DISABLE //< Disable this texture unit (cached)
+ RAS_TEXCO_GEN, /* < GPU will generate texture coordinates */
+ RAS_TEXCO_ORCO, /* < Vertex coordinates (object space) */
+ RAS_TEXCO_GLOB, /* < Vertex coordinates (world space) */
+ RAS_TEXCO_UV, /* < UV coordinates */
+ RAS_TEXCO_OBJECT, /* < Use another object's position as coordinates */
+ RAS_TEXCO_LAVECTOR, /* < Light vector as coordinates */
+ RAS_TEXCO_VIEW, /* < View vector as coordinates */
+ RAS_TEXCO_STICKY, /* < Sticky coordinates */
+ RAS_TEXCO_WINDOW, /* < Window coordinates */
+ RAS_TEXCO_NORM, /* < Normal coordinates */
+ RAS_TEXTANGENT, /* < */
+ RAS_TEXCO_VCOL, /* < Vertex Color */
+ RAS_TEXCO_DISABLE, /* < Disable this texture unit (cached) */
};
/**
* Render pass identifiers for stereo.
*/
enum StereoEye {
- RAS_STEREO_LEFTEYE = 1,
- RAS_STEREO_RIGHTEYE
+ RAS_STEREO_LEFTEYE = 1,
+ RAS_STEREO_RIGHTEYE,
};
/**
@@ -165,167 +165,170 @@ public:
RAS_MIPMAP_NEAREST,
RAS_MIPMAP_LINEAR,
- RAS_MIPMAP_MAX, // Should always be last
+ RAS_MIPMAP_MAX, /* Should always be last */
};
/**
* SetDepthMask enables or disables writing a fragment's depth value
* to the Z buffer.
*/
- virtual void SetDepthMask(DepthMask depthmask)=0;
+ virtual void SetDepthMask(DepthMask depthmask) = 0;
+
/**
* SetMaterial sets the material settings for subsequent primitives
* to be rendered with.
* The material will be cached.
*/
- virtual bool SetMaterial(const RAS_IPolyMaterial& mat)=0;
+ virtual bool SetMaterial(const RAS_IPolyMaterial &mat) = 0;
+
/**
* Init initializes the renderer.
*/
- virtual bool Init()=0;
+ virtual bool Init() = 0;
+
/**
* Exit cleans up the renderer.
*/
- virtual void Exit()=0;
+ virtual void Exit() = 0;
+
/**
* BeginFrame is called at the start of each frame.
*/
- virtual bool BeginFrame(int drawingmode, double time)=0;
+ virtual bool BeginFrame(int drawingmode, double time) = 0;
+
/**
* ClearColorBuffer clears the color buffer.
*/
- virtual void ClearColorBuffer()=0;
+ virtual void ClearColorBuffer() = 0;
+
/**
* ClearDepthBuffer clears the depth buffer.
*/
- virtual void ClearDepthBuffer()=0;
+ virtual void ClearDepthBuffer() = 0;
+
/**
* ClearCachingInfo clears the currently cached material.
*/
- virtual void ClearCachingInfo(void)=0;
+ virtual void ClearCachingInfo(void) = 0;
+
/**
* EndFrame is called at the end of each frame.
*/
- virtual void EndFrame()=0;
+ virtual void EndFrame() = 0;
+
/**
* SetRenderArea sets the render area from the 2d canvas.
* Returns true if only of subset of the canvas is used.
*/
- virtual void SetRenderArea()=0;
+ virtual void SetRenderArea() = 0;
// Stereo Functions
/**
* SetStereoMode will set the stereo mode
*/
- virtual void SetStereoMode(const StereoMode stereomode)=0;
+ virtual void SetStereoMode(const StereoMode stereomode) = 0;
+
/**
* Stereo can be used to query if the rasterizer is in stereo mode.
* \return true if stereo mode is enabled.
*/
- virtual bool Stereo()=0;
- virtual StereoMode GetStereoMode()=0;
- virtual bool InterlacedStereo()=0;
+ virtual bool Stereo() = 0;
+ virtual StereoMode GetStereoMode() = 0;
+ virtual bool InterlacedStereo() = 0;
+
/**
* Sets which eye buffer subsequent primitives will be rendered to.
*/
- virtual void SetEye(const StereoEye eye)=0;
- virtual StereoEye GetEye()=0;
+ virtual void SetEye(const StereoEye eye) = 0;
+ virtual StereoEye GetEye() = 0;
+
/**
* Sets the distance between eyes for stereo mode.
*/
- virtual void SetEyeSeparation(const float eyeseparation)=0;
- virtual float GetEyeSeparation() = 0;
+ virtual void SetEyeSeparation(const float eyeseparation) = 0;
+ virtual float GetEyeSeparation() = 0;
+
/**
* Sets the focal length for stereo mode.
*/
- virtual void SetFocalLength(const float focallength)=0;
- virtual float GetFocalLength() = 0;
+ virtual void SetFocalLength(const float focallength) = 0;
+ virtual float GetFocalLength() = 0;
+
/**
* SwapBuffers swaps the back buffer with the front buffer.
*/
- virtual void SwapBuffers()=0;
+ virtual void SwapBuffers() = 0;
// Drawing Functions
/**
* IndexPrimitives: Renders primitives from mesh slot.
*/
- virtual void IndexPrimitives(class RAS_MeshSlot& ms)=0;
- virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms)=0;
+ virtual void IndexPrimitives(class RAS_MeshSlot &ms) = 0;
+ virtual void IndexPrimitivesMulti(class RAS_MeshSlot &ms) = 0;
/**
* IndexPrimitives_3DText will render text into the polygons.
*/
- virtual void IndexPrimitives_3DText(class RAS_MeshSlot& ms,
- class RAS_IPolyMaterial* polymat)=0;
+ virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat) = 0;
+
+ virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat) = 0;
- virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat)=0;
/* This one should become our final version, methinks. */
/**
* Set the projection matrix for the rasterizer. This projects
* from camera coordinates to window coordinates.
* \param mat The projection matrix.
*/
- virtual void SetProjectionMatrix(const MT_Matrix4x4 & mat)=0;
+ virtual void SetProjectionMatrix(const MT_Matrix4x4 &mat) = 0;
+
/**
* Sets the modelview matrix.
*/
- virtual void SetViewMatrix(const MT_Matrix4x4 & mat,
- const MT_Matrix3x3 & ori,
- const MT_Point3 & pos,
- bool perspective)=0;
- /**
- */
- virtual const MT_Point3& GetCameraPosition()=0;
- virtual bool GetCameraOrtho()=0;
+ virtual void SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Matrix3x3 &ori,
+ const MT_Point3 &pos, bool perspective) = 0;
/**
*/
- virtual void SetFog(float start,
- float dist,
- float r,
- float g,
- float b)=0;
-
- virtual void SetFogColor(float r,
- float g,
- float b)=0;
+ virtual const MT_Point3& GetCameraPosition() = 0;
+ virtual bool GetCameraOrtho() = 0;
- virtual void SetFogStart(float start)=0;
- /**
- */
- virtual void SetFogEnd(float end)=0;
/**
+ * Fog
*/
- virtual void DisplayFog()=0;
- /**
- */
- virtual void DisableFog()=0;
- virtual bool IsFogEnabled()=0;
+ virtual void SetFog(float start, float dist, float r, float g, float b) = 0;
+ virtual void SetFogColor(float r, float g,float b) = 0;
+ virtual void SetFogStart(float start) = 0;
+ virtual void SetFogEnd(float end) = 0;
+ virtual void DisplayFog() = 0;
+ virtual void DisableFog() = 0;
+ virtual bool IsFogEnabled() = 0;
- virtual void SetBackColor(float red,
- float green,
- float blue,
- float alpha)=0;
+ virtual void SetBackColor(float red, float green, float blue, float alpha) = 0;
/**
* \param drawingmode = KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED.
*/
- virtual void SetDrawingMode(int drawingmode)=0;
+ virtual void SetDrawingMode(int drawingmode) = 0;
+
/**
* \return the current drawing mode: KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED.
*/
- virtual int GetDrawingMode()=0;
+ virtual int GetDrawingMode() = 0;
+
/**
* Sets face culling
*/
- virtual void SetCullFace(bool enable)=0;
+ virtual void SetCullFace(bool enable) = 0;
+
/**
* Sets wireframe mode.
*/
- virtual void SetLines(bool enable)=0;
+ virtual void SetLines(bool enable) = 0;
+
/**
*/
- virtual double GetTime()=0;
+ virtual double GetTime() = 0;
+
/**
* Generates a projection matrix from the specified frustum.
* \param left the left clipping plane
@@ -337,15 +340,9 @@ public:
* \return a 4x4 matrix representing the projection transform.
*/
virtual MT_Matrix4x4 GetFrustumMatrix(
- float left,
- float right,
- float bottom,
- float top,
- float frustnear,
- float frustfar,
- float focallength = 0.0f,
- bool perspective = true
- )=0;
+ float left, float right, float bottom, float top,
+ float frustnear, float frustfar,
+ float focallength = 0.0f, bool perspective = true) = 0;
/**
* Generates a orthographic projection matrix from the specified frustum.
@@ -358,91 +355,76 @@ public:
* \return a 4x4 matrix representing the projection transform.
*/
virtual MT_Matrix4x4 GetOrthoMatrix(
- float left,
- float right,
- float bottom,
- float top,
- float frustnear,
- float frustfar
- )=0;
+ float left, float right, float bottom, float top,
+ float frustnear, float frustfar) = 0;
/**
* Sets the specular color component of the lighting equation.
*/
- virtual void SetSpecularity(float specX,
- float specY,
- float specZ,
- float specval)=0;
+ virtual void SetSpecularity(float specX, float specY, float specZ, float specval) = 0;
/**
* Sets the specular exponent component of the lighting equation.
*/
- virtual void SetShinyness(float shiny)=0;
+ virtual void SetShinyness(float shiny) = 0;
+
/**
* Sets the diffuse color component of the lighting equation.
*/
- virtual void SetDiffuse(float difX,
- float difY,
- float difZ,
- float diffuse)=0;
+ virtual void SetDiffuse(float difX,float difY, float difZ, float diffuse) = 0;
+
/**
* Sets the emissive color component of the lighting equation.
*/
- virtual void SetEmissive(float eX,
- float eY,
- float eZ,
- float e
- )=0;
+ virtual void SetEmissive(float eX, float eY, float eZ, float e) = 0;
- virtual void SetAmbientColor(float red, float green, float blue)=0;
- virtual void SetAmbient(float factor)=0;
+ virtual void SetAmbientColor(float red, float green, float blue) = 0;
+ virtual void SetAmbient(float factor) = 0;
/**
* Sets a polygon offset. z depth will be: z1 = mult*z0 + add
*/
virtual void SetPolygonOffset(float mult, float add) = 0;
- virtual void DrawDebugLine(const MT_Vector3& from, const MT_Vector3& to, const MT_Vector3& color)=0;
- virtual void DrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color,
- const MT_Vector3& normal, int nsector)=0;
- virtual void FlushDebugShapes()=0;
+ virtual void DrawDebugLine(const MT_Vector3 &from, const MT_Vector3 &to, const MT_Vector3& color) = 0;
+ virtual void DrawDebugCircle(const MT_Vector3 &center, const MT_Scalar radius, const MT_Vector3 &color,
+ const MT_Vector3 &normal, int nsector) = 0;
+ virtual void FlushDebugShapes() = 0;
+ virtual void SetTexCoordNum(int num) = 0;
+ virtual void SetAttribNum(int num) = 0;
+ virtual void SetTexCoord(TexCoGen coords, int unit) = 0;
+ virtual void SetAttrib(TexCoGen coords, int unit, int layer = 0) = 0;
+ virtual const MT_Matrix4x4 &GetViewMatrix() const = 0;
+ virtual const MT_Matrix4x4 &GetViewInvMatrix() const = 0;
- virtual void SetTexCoordNum(int num) = 0;
- virtual void SetAttribNum(int num) = 0;
- virtual void SetTexCoord(TexCoGen coords, int unit) = 0;
- virtual void SetAttrib(TexCoGen coords, int unit, int layer = 0) = 0;
-
- virtual const MT_Matrix4x4& GetViewMatrix() const = 0;
- virtual const MT_Matrix4x4& GetViewInvMatrix() const = 0;
-
- virtual bool QueryLists() { return false; }
- virtual bool QueryArrays() { return false; }
+ virtual bool QueryLists() { return false; }
+ virtual bool QueryArrays() { return false; }
- virtual void EnableMotionBlur(float motionblurvalue)=0;
- virtual void DisableMotionBlur()=0;
+ virtual void EnableMotionBlur(float motionblurvalue) = 0;
+ virtual void DisableMotionBlur() = 0;
- virtual float GetMotionBlurValue()=0;
- virtual int GetMotionBlurState()=0;
- virtual void SetMotionBlurState(int newstate)=0;
+ virtual float GetMotionBlurValue() = 0;
+ virtual int GetMotionBlurState() = 0;
+ virtual void SetMotionBlurState(int newstate) = 0;
- virtual void SetAlphaBlend(int alphablend)=0;
- virtual void SetFrontFace(bool ccw)=0;
+ virtual void SetAlphaBlend(int alphablend) = 0;
+ virtual void SetFrontFace(bool ccw) = 0;
- virtual void SetAnisotropicFiltering(short level)=0;
- virtual short GetAnisotropicFiltering()=0;
+ virtual void SetAnisotropicFiltering(short level) = 0;
+ virtual short GetAnisotropicFiltering() = 0;
- virtual void SetMipmapping(MipmapOption val)=0;
- virtual MipmapOption GetMipmapping()=0;
+ virtual void SetMipmapping(MipmapOption val) = 0;
+ virtual MipmapOption GetMipmapping() = 0;
- virtual void SetUsingOverrideShader(bool val)=0;
- virtual bool GetUsingOverrideShader()=0;
+ virtual void SetUsingOverrideShader(bool val) = 0;
+ virtual bool GetUsingOverrideShader() = 0;
/**
* Render Tools
*/
- virtual void applyTransform(double* oglmatrix, int drawingmode)=0;
+ virtual void applyTransform(double *oglmatrix, int drawingmode) = 0;
/**
* Renders 2D boxes.
@@ -452,11 +434,7 @@ public:
* \param height Height of the canvas to draw to.
* \param percentage Percentage of bar.
*/
- virtual void RenderBox2D(int xco,
- int yco,
- int width,
- int height,
- float percentage) = 0;
+ virtual void RenderBox2D(int xco, int yco, int width, int height, float percentage) = 0;
/**
* Renders 3D text string using BFL.
@@ -468,15 +446,9 @@ public:
* \param mat The Matrix of the text object.
* \param aspect A scaling factor to compensate for the size.
*/
- virtual void RenderText3D(int fontid,
- const char* text,
- int size,
- int dpi,
- float* color,
- double* mat,
- float aspect
- ) = 0;
-
+ virtual void RenderText3D(
+ int fontid, const char *text, int size, int dpi,
+ const float color[4], const double mat[16], float aspect) = 0;
/**
* Renders 2D text string.
@@ -487,29 +459,25 @@ public:
* \param width Width of the canvas to draw to.
* \param height Height of the canvas to draw to.
*/
- virtual void RenderText2D(RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height
- ) = 0;
+ virtual void RenderText2D(
+ RAS_TEXT_RENDER_MODE mode, const char *text,
+ int xco, int yco, int width, int height) = 0;
- virtual void ProcessLighting(bool uselights, const MT_Transform& trans)=0;
+ virtual void ProcessLighting(bool uselights, const MT_Transform &trans) = 0;
- virtual void PushMatrix()=0;
+ virtual void PushMatrix() = 0;
- virtual void PopMatrix()=0;
+ virtual void PopMatrix() = 0;
- virtual void AddLight(struct RAS_LightObject* lightobject)=0;
+ virtual void AddLight(struct RAS_LightObject *lightobject) = 0;
- virtual void RemoveLight(struct RAS_LightObject* lightobject)=0;
+ virtual void RemoveLight(struct RAS_LightObject *lightobject) = 0;
- virtual void MotionBlur()=0;
+ virtual void MotionBlur() = 0;
- virtual void SetClientObject(void* obj)=0;
+ virtual void SetClientObject(void *obj) = 0;
- virtual void SetAuxilaryClientInfo(void* inf)=0;
+ virtual void SetAuxilaryClientInfo(void *inf) = 0;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IRasterizer")
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index 2884983a17e..fc5e1135fa8 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -1439,13 +1439,9 @@ void RAS_OpenGLRasterizer::RenderBox2D(int xco,
glEnable(GL_DEPTH_TEST);
}
-void RAS_OpenGLRasterizer::RenderText3D(int fontid,
- const char* text,
- int size,
- int dpi,
- float* color,
- double* mat,
- float aspect)
+void RAS_OpenGLRasterizer::RenderText3D(
+ int fontid, const char *text, int size, int dpi,
+ const float color[4], const double mat[16], float aspect)
{
/* gl prepping */
DisableForText();
@@ -1464,17 +1460,16 @@ void RAS_OpenGLRasterizer::RenderText3D(int fontid,
BLF_size(fontid, size, dpi);
BLF_position(fontid, 0, 0, 0);
- BLF_draw(fontid, (char *)text, 65535);
+ BLF_draw(fontid, text, 65535);
BLF_disable(fontid, BLF_MATRIX|BLF_ASPECT);
}
-void RAS_OpenGLRasterizer::RenderText2D(RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height)
+void RAS_OpenGLRasterizer::RenderText2D(
+ RAS_TEXT_RENDER_MODE mode,
+ const char* text,
+ int xco, int yco,
+ int width, int height)
{
/* This is a rather important line :( The gl-mode hasn't been left
* behind quite as neatly as we'd have wanted to. I don't know
@@ -1497,14 +1492,14 @@ void RAS_OpenGLRasterizer::RenderText2D(RAS_TEXT_RENDER_MODE mode,
glColor3ub(0, 0, 0);
BLF_size(blf_mono_font, 11, 72);
BLF_position(blf_mono_font, (float)xco+1, (float)(height-yco-1), 0.0f);
- BLF_draw(blf_mono_font, (char *)text, 65535);/* XXX, use real len */
+ BLF_draw(blf_mono_font, text, 65535); /* XXX, use real len */
}
/* the actual drawing */
glColor3ub(255, 255, 255);
BLF_size(blf_mono_font, 11, 72);
BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f);
- BLF_draw(blf_mono_font, (char *)text, 65535); /* XXX, use real len */
+ BLF_draw(blf_mono_font, text, 65535); /* XXX, use real len */
glMatrixMode(GL_PROJECTION);
glPopMatrix();
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
index 01c42050b36..d03e06c3b31 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
@@ -47,26 +47,27 @@ using namespace std;
class RAS_IStorage;
class RAS_ICanvas;
-#define RAS_MAX_TEXCO 8 // match in BL_Material
-#define RAS_MAX_ATTRIB 16 // match in BL_BlenderShader
+#define RAS_MAX_TEXCO 8 /* match in BL_Material */
+#define RAS_MAX_ATTRIB 16 /* match in BL_BlenderShader */
enum RAS_STORAGE_TYPE {
RAS_AUTO_STORAGE,
RAS_IMMEDIATE,
RAS_VA,
- RAS_VBO
+ RAS_VBO,
};
-struct OglDebugShape
+struct OglDebugShape
{
enum SHAPE_TYPE{
- LINE, CIRCLE
+ LINE,
+ CIRCLE,
};
- SHAPE_TYPE m_type;
- MT_Vector3 m_pos;
- MT_Vector3 m_param;
- MT_Vector3 m_param2;
- MT_Vector3 m_color;
+ SHAPE_TYPE m_type;
+ MT_Vector3 m_pos;
+ MT_Vector3 m_param;
+ MT_Vector3 m_param2;
+ MT_Vector3 m_color;
};
/**
@@ -74,78 +75,76 @@ struct OglDebugShape
*/
class RAS_OpenGLRasterizer : public RAS_IRasterizer
{
-
- RAS_ICanvas* m_2DCanvas;
+ RAS_ICanvas *m_2DCanvas;
- // fogging vars
- bool m_fogenabled;
- float m_fogstart;
- float m_fogdist;
- float m_fogr;
- float m_fogg;
- float m_fogb;
+ /* fogging vars */
+ bool m_fogenabled;
+ float m_fogstart;
+ float m_fogdist;
+ float m_fogr;
+ float m_fogg;
+ float m_fogb;
- float m_redback;
- float m_greenback;
- float m_blueback;
- float m_alphaback;
+ float m_redback;
+ float m_greenback;
+ float m_blueback;
+ float m_alphaback;
- float m_ambr;
- float m_ambg;
- float m_ambb;
- double m_time;
- MT_Matrix4x4 m_viewmatrix;
- MT_Matrix4x4 m_viewinvmatrix;
- MT_Point3 m_campos;
- bool m_camortho;
-
- StereoMode m_stereomode;
- StereoEye m_curreye;
- float m_eyeseparation;
- float m_focallength;
- bool m_setfocallength;
- int m_noOfScanlines;
-
- short m_prevafvalue;
-
- //motion blur
- int m_motionblur;
- float m_motionblurvalue;
+ float m_ambr;
+ float m_ambg;
+ float m_ambb;
+ double m_time;
+ MT_Matrix4x4 m_viewmatrix;
+ MT_Matrix4x4 m_viewinvmatrix;
+ MT_Point3 m_campos;
+ bool m_camortho;
+
+ StereoMode m_stereomode;
+ StereoEye m_curreye;
+ float m_eyeseparation;
+ float m_focallength;
+ bool m_setfocallength;
+ int m_noOfScanlines;
+
+ short m_prevafvalue;
+
+ /* motion blur */
+ int m_motionblur;
+ float m_motionblurvalue;
bool m_usingoverrideshader;
- // Render tools
- void* m_clientobject;
- void* m_auxilaryClientInfo;
- std::vector<struct RAS_LightObject*> m_lights;
- int m_lastlightlayer;
- bool m_lastlighting;
- void *m_lastauxinfo;
+ /* Render tools */
+ void *m_clientobject;
+ void *m_auxilaryClientInfo;
+ std::vector<struct RAS_LightObject *> m_lights;
+ int m_lastlightlayer;
+ bool m_lastlighting;
+ void *m_lastauxinfo;
unsigned int m_numgllights;
protected:
- int m_drawingmode;
- TexCoGen m_texco[RAS_MAX_TEXCO];
- TexCoGen m_attrib[RAS_MAX_ATTRIB];
- int m_attrib_layer[RAS_MAX_ATTRIB];
- int m_texco_num;
- int m_attrib_num;
- //int m_last_alphablend;
- bool m_last_frontface;
-
- /** Stores the caching information for the last material activated. */
+ int m_drawingmode;
+ TexCoGen m_texco[RAS_MAX_TEXCO];
+ TexCoGen m_attrib[RAS_MAX_ATTRIB];
+ int m_attrib_layer[RAS_MAX_ATTRIB];
+ int m_texco_num;
+ int m_attrib_num;
+ /* int m_last_alphablend; */
+ bool m_last_frontface;
+
+ /* Stores the caching information for the last material activated. */
RAS_IPolyMaterial::TCachingInfo m_materialCachingInfo;
- /**
- * Making use of a Strategy design pattern for storage behavior.
+ /* Making use of a Strategy design pattern for storage behavior.
* Examples of concrete strategies: Vertex Arrays, VBOs, Immediate Mode*/
- int m_storage_type;
- RAS_IStorage* m_storage;
- RAS_IStorage* m_failsafe_storage; //So derived mesh can use immediate mode
+ int m_storage_type;
+ RAS_IStorage *m_storage;
+ RAS_IStorage *m_failsafe_storage; /* So derived mesh can use immediate mode */
public:
double GetTime();
- RAS_OpenGLRasterizer(RAS_ICanvas* canv, int storage=RAS_AUTO_STORAGE);
+ RAS_OpenGLRasterizer(RAS_ICanvas *canv, int storage=RAS_AUTO_STORAGE);
virtual ~RAS_OpenGLRasterizer();
/*enum DrawType
@@ -162,130 +161,79 @@ public:
KX_DEPTHMASK_ENABLED =1,
KX_DEPTHMASK_DISABLED,
};*/
- virtual void SetDepthMask(DepthMask depthmask);
-
- virtual bool SetMaterial(const RAS_IPolyMaterial& mat);
- virtual bool Init();
- virtual void Exit();
- virtual bool BeginFrame(int drawingmode, double time);
- virtual void ClearColorBuffer();
- virtual void ClearDepthBuffer();
- virtual void ClearCachingInfo(void);
- virtual void EndFrame();
- virtual void SetRenderArea();
-
- virtual void SetStereoMode(const StereoMode stereomode);
+ virtual void SetDepthMask(DepthMask depthmask);
+
+ virtual bool SetMaterial(const RAS_IPolyMaterial &mat);
+ virtual bool Init();
+ virtual void Exit();
+ virtual bool BeginFrame(int drawingmode, double time);
+ virtual void ClearColorBuffer();
+ virtual void ClearDepthBuffer();
+ virtual void ClearCachingInfo(void);
+ virtual void EndFrame();
+ virtual void SetRenderArea();
+
+ virtual void SetStereoMode(const StereoMode stereomode);
virtual RAS_IRasterizer::StereoMode GetStereoMode();
- virtual bool Stereo();
- virtual bool InterlacedStereo();
- virtual void SetEye(const StereoEye eye);
- virtual StereoEye GetEye();
- virtual void SetEyeSeparation(const float eyeseparation);
- virtual float GetEyeSeparation();
- virtual void SetFocalLength(const float focallength);
- virtual float GetFocalLength();
-
- virtual void SwapBuffers();
-
- virtual void IndexPrimitives(class RAS_MeshSlot& ms);
- virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms);
- virtual void IndexPrimitives_3DText(class RAS_MeshSlot& ms,
- class RAS_IPolyMaterial* polymat);
-
- virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat);
- virtual void SetProjectionMatrix(const MT_Matrix4x4 & mat);
- virtual void SetViewMatrix(
- const MT_Matrix4x4 & mat,
- const MT_Matrix3x3 & ori,
- const MT_Point3 & pos,
- bool perspective
- );
-
- virtual const MT_Point3& GetCameraPosition();
- virtual bool GetCameraOrtho();
+ virtual bool Stereo();
+ virtual bool InterlacedStereo();
+ virtual void SetEye(const StereoEye eye);
+ virtual StereoEye GetEye();
+ virtual void SetEyeSeparation(const float eyeseparation);
+ virtual float GetEyeSeparation();
+ virtual void SetFocalLength(const float focallength);
+ virtual float GetFocalLength();
+
+ virtual void SwapBuffers();
+
+ virtual void IndexPrimitives(class RAS_MeshSlot &ms);
+ virtual void IndexPrimitivesMulti(class RAS_MeshSlot &ms);
+ virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat);
+
+ virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat);
+ virtual void SetProjectionMatrix(const MT_Matrix4x4 &mat);
+ virtual void SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Matrix3x3 &ori, const MT_Point3 &pos, bool perspective);
+
+ virtual const MT_Point3& GetCameraPosition();
+ virtual bool GetCameraOrtho();
- virtual void SetFog(
- float start,
- float dist,
- float r,
- float g,
- float b
- );
-
- virtual void SetFogColor(
- float r,
- float g,
- float b
- );
-
- virtual void SetFogStart(float fogstart);
- virtual void SetFogEnd(float fogend);
-
- void DisableFog();
- virtual void DisplayFog();
- virtual bool IsFogEnabled();
-
- virtual void SetBackColor(
- float red,
- float green,
- float blue,
- float alpha
- );
+ virtual void SetFog(float start, float dist, float r, float g, float b);
+ virtual void SetFogColor(float r, float g, float b);
+ virtual void SetFogStart(float fogstart);
+ virtual void SetFogEnd(float fogend);
+ void DisableFog();
+ virtual void DisplayFog();
+ virtual bool IsFogEnabled();
+
+ virtual void SetBackColor(float red, float green, float blue, float alpha);
- virtual void SetDrawingMode(int drawingmode);
- virtual int GetDrawingMode();
+ virtual void SetDrawingMode(int drawingmode);
+ virtual int GetDrawingMode();
- virtual void SetCullFace(bool enable);
- virtual void SetLines(bool enable);
+ virtual void SetCullFace(bool enable);
+ virtual void SetLines(bool enable);
virtual MT_Matrix4x4 GetFrustumMatrix(
- float left,
- float right,
- float bottom,
- float top,
- float frustnear,
- float frustfar,
- float focallength,
- bool perspective
- );
-
+ float left, float right, float bottom, float top,
+ float frustnear, float frustfar,
+ float focallength, bool perspective);
virtual MT_Matrix4x4 GetOrthoMatrix(
- float left,
- float right,
- float bottom,
- float top,
- float frustnear,
- float frustfar
- );
-
- virtual void SetSpecularity(
- float specX,
- float specY,
- float specZ,
- float specval
- );
-
- virtual void SetShinyness(float shiny);
- virtual void SetDiffuse(
- float difX,
- float difY,
- float difZ,
- float diffuse
- );
- virtual void SetEmissive(float eX,
- float eY,
- float eZ,
- float e
- );
-
- virtual void SetAmbientColor(float red, float green, float blue);
- virtual void SetAmbient(float factor);
-
- virtual void SetPolygonOffset(float mult, float add);
-
- virtual void FlushDebugShapes();
-
- virtual void DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)
+ float left, float right, float bottom, float top,
+ float frustnear, float frustfar);
+
+ virtual void SetSpecularity(float specX, float specY, float specZ, float specval);
+ virtual void SetShinyness(float shiny);
+ virtual void SetDiffuse(float difX, float difY, float difZ, float diffuse);
+ virtual void SetEmissive(float eX, float eY, float eZ, float e);
+
+ virtual void SetAmbientColor(float red, float green, float blue);
+ virtual void SetAmbient(float factor);
+
+ virtual void SetPolygonOffset(float mult, float add);
+
+ virtual void FlushDebugShapes();
+
+ virtual void DrawDebugLine(const MT_Vector3 &from,const MT_Vector3 &to, const MT_Vector3 &color)
{
OglDebugShape line;
line.m_type = OglDebugShape::LINE;
@@ -295,8 +243,8 @@ public:
m_debugShapes.push_back(line);
}
- virtual void DrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color,
- const MT_Vector3& normal, int nsector)
+ virtual void DrawDebugCircle(const MT_Vector3 &center, const MT_Scalar radius, const MT_Vector3 &color,
+ const MT_Vector3 &normal, int nsector)
{
OglDebugShape line;
line.m_type = OglDebugShape::CIRCLE;
@@ -317,14 +265,14 @@ public:
void TexCoord(const RAS_TexVert &tv);
- const MT_Matrix4x4& GetViewMatrix() const;
- const MT_Matrix4x4& GetViewInvMatrix() const;
+ const MT_Matrix4x4 &GetViewMatrix() const;
+ const MT_Matrix4x4 &GetViewInvMatrix() const;
- virtual void EnableMotionBlur(float motionblurvalue);
- virtual void DisableMotionBlur();
- virtual float GetMotionBlurValue() { return m_motionblurvalue; }
- virtual int GetMotionBlurState() { return m_motionblur; }
- virtual void SetMotionBlurState(int newstate)
+ virtual void EnableMotionBlur(float motionblurvalue);
+ virtual void DisableMotionBlur();
+ virtual float GetMotionBlurValue() { return m_motionblurvalue; }
+ virtual int GetMotionBlurState() { return m_motionblur; }
+ virtual void SetMotionBlurState(int newstate)
{
if (newstate < 0)
m_motionblur = 0;
@@ -332,68 +280,50 @@ public:
m_motionblur = 2;
else
m_motionblur = newstate;
- };
+ }
- virtual void SetAlphaBlend(int alphablend);
- virtual void SetFrontFace(bool ccw);
+ virtual void SetAlphaBlend(int alphablend);
+ virtual void SetFrontFace(bool ccw);
- virtual void SetAnisotropicFiltering(short level);
- virtual short GetAnisotropicFiltering();
+ virtual void SetAnisotropicFiltering(short level);
+ virtual short GetAnisotropicFiltering();
- virtual void SetMipmapping(MipmapOption val);
+ virtual void SetMipmapping(MipmapOption val);
virtual MipmapOption GetMipmapping();
- virtual void SetUsingOverrideShader(bool val);
- virtual bool GetUsingOverrideShader();
+ virtual void SetUsingOverrideShader(bool val);
+ virtual bool GetUsingOverrideShader();
/**
* Render Tools
*/
- void EnableOpenGLLights();
- void DisableOpenGLLights();
- void ProcessLighting(bool uselights, const MT_Transform& viewmat);
-
- void RenderBox2D(int xco,
- int yco,
- int width,
- int height,
- float percentage);
-
-
- void RenderText3D(int fontid,
- const char* text,
- int size,
- int dpi,
- float* color,
- double* mat,
- float aspect);
-
- void RenderText2D(RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height);
-
- void applyTransform(double* oglmatrix, int objectdrawmode);
+ void EnableOpenGLLights();
+ void DisableOpenGLLights();
+ void ProcessLighting(bool uselights, const MT_Transform &viewmat);
- void PushMatrix();
- void PopMatrix();
+ void RenderBox2D(int xco, int yco, int width, int height, float percentage);
+ void RenderText3D(int fontid, const char *text, int size, int dpi,
+ const float color[4], const double mat[16], float aspect);
+ void RenderText2D(RAS_TEXT_RENDER_MODE mode, const char *text,
+ int xco, int yco, int width, int height);
- bool RayHit(struct KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data);
- bool NeedRayCast(struct KX_ClientObjectInfo*) { return true; }
+ void applyTransform(double *oglmatrix, int objectdrawmode);
+ void PushMatrix();
+ void PopMatrix();
- void AddLight(struct RAS_LightObject* lightobject);
+ bool RayHit(struct KX_ClientObjectInfo *client, class KX_RayCast *result, void * const data);
+ bool NeedRayCast(struct KX_ClientObjectInfo *) { return true; }
- void RemoveLight(struct RAS_LightObject* lightobject);
- int ApplyLights(int objectlayer, const MT_Transform& viewmat);
+ void AddLight(struct RAS_LightObject *lightobject);
+ void RemoveLight(struct RAS_LightObject *lightobject);
+ int ApplyLights(int objectlayer, const MT_Transform &viewmat);
void MotionBlur();
- void SetClientObject(void* obj);
+ void SetClientObject(void *obj);
- void SetAuxilaryClientInfo(void* inf);
+ void SetAuxilaryClientInfo(void *inf);
#ifdef WITH_CXX_GUARDEDALLOC