[Bf-blender-cvs] [fcffa4b] temp_merge_gooseberry_hair: Moved the cloth solver code into a new subfolder/library inside Blender code.

Lukas Tönne noreply at git.blender.org
Mon Jan 19 20:48:56 CET 2015


Commit: fcffa4b1f6d94dcefafdb4932a1d7654bdce03bb
Author: Lukas Tönne
Date:   Sat Sep 13 14:36:46 2014 +0200
Branches: temp_merge_gooseberry_hair
https://developer.blender.org/rBfcffa4b1f6d94dcefafdb4932a1d7654bdce03bb

Moved the cloth solver code into a new subfolder/library inside Blender
code.

The implicit solver itself should remain agnostic to the specifics of
the Blender data (cloth vs. hair). This way we could avoid the bloated
data conversion chain from particles/hair to derived mesh to cloth
modifier to implicit solver data and back. Every step in this chain adds
overhead as well as rounding errors and a possibility for bugs, not to
speak of making the code horribly complicated.

The new subfolder is named "physics" since it should be the start of a
somewhat "unified" physics systems combining all the various solvers in
the same place and managing things like synchronized time steps.

===================================================================

M	build_files/cmake/macros.cmake
M	source/blender/CMakeLists.txt
M	source/blender/blenkernel/BKE_cloth.h
M	source/blender/blenkernel/CMakeLists.txt
D	source/blender/blenkernel/intern/ConstrainedConjugateGradient.h
M	source/blender/blenkernel/intern/cloth.c
D	source/blender/blenkernel/intern/implicit.c
D	source/blender/blenkernel/intern/implicit.h
D	source/blender/blenkernel/intern/implicit_eigen.cpp
A	source/blender/physics/BPH_mass_spring.h
A	source/blender/physics/CMakeLists.txt
A	source/blender/physics/intern/BPH_mass_spring.cpp
A	source/blender/physics/intern/ConstrainedConjugateGradient.h
A	source/blender/physics/intern/implicit.h
A	source/blender/physics/intern/implicit_blender.c
A	source/blender/physics/intern/implicit_eigen.cpp
M	source/blender/render/intern/source/voxeldata.c

===================================================================

diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 40bea5e..86732a9 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -500,6 +500,7 @@ macro(SETUP_BLENDER_SORTED_LIBS)
 		bf_modifiers
 		bf_bmesh
 		bf_blenkernel
+		bf_physics
 		bf_nodes
 		bf_rna
 		bf_gpu
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 0d30952..1cc232a 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -102,6 +102,7 @@ add_subdirectory(render)
 add_subdirectory(blenfont)
 add_subdirectory(blenloader)
 add_subdirectory(ikplugin)
+add_subdirectory(physics)
 add_subdirectory(gpu)
 add_subdirectory(imbuf)
 add_subdirectory(nodes)
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index e0710ee..3dec5c8 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -209,19 +209,6 @@ void cloth_free_contacts(ColliderContacts *collider_contacts, int totcolliders);
 
 ////////////////////////////////////////////////
 
-
-////////////////////////////////////////////////
-// implicit.c
-////////////////////////////////////////////////
-
-// needed for cloth.c
-int implicit_init (struct Object *ob, struct ClothModifierData *clmd );
-int implicit_free (struct ClothModifierData *clmd );
-int implicit_solver (struct Object *ob, float frame, struct ClothModifierData *clmd, struct ListBase *effectors );
-void implicit_set_positions (struct ClothModifierData *clmd );
-
-bool implicit_hair_volume_get_texture_data(struct Object *UNUSED(ob), struct ClothModifierData *clmd, struct ListBase *UNUSED(effectors), struct VoxelData *vd);
-
 /////////////////////////////////////////////////
 // cloth.c
 ////////////////////////////////////////////////
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index aabc558..fa4952d 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -36,6 +36,7 @@ set(INC
 	../bmesh
 	../modifiers
 	../nodes
+	../physics
 	../render/extern/include
 	../../../intern/ghost
 	../../../intern/guardedalloc
@@ -47,7 +48,6 @@ set(INC
 	../../../intern/smoke/extern
 	../../../intern/atomic
 	../../../extern/libmv
-	../../../extern/Eigen3
 
 	# XXX - BAD LEVEL CALL WM_api.h
 	../windowmanager
@@ -106,10 +106,6 @@ set(SRC
 	intern/idprop.c
 	intern/image.c
 	intern/image_gen.c
-        intern/implicit.h
-        intern/implicit.c
-	intern/implicit_eigen.cpp
-        intern/ConstrainedConjugateGradient.h # XXX move this to a better place
 	intern/ipo.c
 	intern/key.c
 	intern/lamp.c
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 3932a8e..89ad084 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -47,6 +47,8 @@
 #include "BKE_modifier.h"
 #include "BKE_pointcache.h"
 
+#include "BPH_mass_spring.h"
+
 // #include "PIL_time.h"  /* timing for debug prints */
 
 /* Our available solvers. */
diff --git a/source/blender/blenkernel/intern/implicit.h b/source/blender/physics/BPH_mass_spring.h
similarity index 60%
copy from source/blender/blenkernel/intern/implicit.h
copy to source/blender/physics/BPH_mass_spring.h
index 31b8069..2960082 100644
--- a/source/blender/blenkernel/intern/implicit.h
+++ b/source/blender/physics/BPH_mass_spring.h
@@ -25,36 +25,14 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef __BKE_IMPLICIT_H__
-#define __BKE_IMPLICIT_H__
+#ifndef __BPH_MASS_SPRING_H__
+#define __BPH_MASS_SPRING_H__
 
-/** \file implicit.h
- *  \ingroup bke
- */
-
-#include "stdio.h"
-
-#include "BLI_utildefines.h"
-
-//#define IMPLICIT_SOLVER_EIGEN
-#define IMPLICIT_SOLVER_BLENDER
-
-#define CLOTH_ROOT_FRAME /* enable use of root frame coordinate transform */
-
-#define CLOTH_FORCE_GRAVITY
-#define CLOTH_FORCE_DRAG
-#define CLOTH_FORCE_SPRING_STRUCTURAL
-#define CLOTH_FORCE_SPRING_BEND
-#define CLOTH_FORCE_SPRING_GOAL
-#define CLOTH_FORCE_EFFECTORS
-
-//#define IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
-
-//#define IMPLICIT_ENABLE_EIGEN_DEBUG
+int implicit_init (struct Object *ob, struct ClothModifierData *clmd );
+int implicit_free (struct ClothModifierData *clmd );
+int implicit_solver (struct Object *ob, float frame, struct ClothModifierData *clmd, struct ListBase *effectors );
+void implicit_set_positions (struct ClothModifierData *clmd );
 
-BLI_INLINE void implicit_print_matrix_elem(float v)
-{
-    printf("%-8.3f", v);
-}
+bool implicit_hair_volume_get_texture_data(struct Object *UNUSED(ob), struct ClothModifierData *clmd, struct ListBase *UNUSED(effectors), struct VoxelData *vd);
 
 #endif
diff --git a/source/blender/physics/CMakeLists.txt b/source/blender/physics/CMakeLists.txt
new file mode 100644
index 0000000..b08cf17
--- /dev/null
+++ b/source/blender/physics/CMakeLists.txt
@@ -0,0 +1,51 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2014, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Lukas Toenne
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+	.
+	intern
+	../blenlib
+	../blenkernel
+	../imbuf
+	../makesdna
+	../../../intern/guardedalloc
+	../../../extern/Eigen3
+)
+
+set(INC_SYS
+
+)
+
+set(SRC
+	intern/BPH_mass_spring.cpp
+	intern/ConstrainedConjugateGradient.h
+	intern/implicit.h
+	intern/implicit_blender.c
+	intern/implicit_eigen.cpp
+
+	BPH_mass_spring.h
+)
+
+blender_add_lib(bf_physics "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
new file mode 100644
index 0000000..e69de29
diff --git a/source/blender/blenkernel/intern/ConstrainedConjugateGradient.h b/source/blender/physics/intern/ConstrainedConjugateGradient.h
similarity index 100%
rename from source/blender/blenkernel/intern/ConstrainedConjugateGradient.h
rename to source/blender/physics/intern/ConstrainedConjugateGradient.h
diff --git a/source/blender/blenkernel/intern/implicit.h b/source/blender/physics/intern/implicit.h
similarity index 95%
rename from source/blender/blenkernel/intern/implicit.h
rename to source/blender/physics/intern/implicit.h
index 31b8069..edddd1b 100644
--- a/source/blender/blenkernel/intern/implicit.h
+++ b/source/blender/physics/intern/implicit.h
@@ -25,11 +25,11 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef __BKE_IMPLICIT_H__
-#define __BKE_IMPLICIT_H__
+#ifndef __BPH_IMPLICIT_H__
+#define __BPH_IMPLICIT_H__
 
 /** \file implicit.h
- *  \ingroup bke
+ *  \ingroup bph
  */
 
 #include "stdio.h"
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/physics/intern/implicit_blender.c
similarity index 99%
rename from source/blender/blenkernel/intern/implicit.c
rename to source/blender/physics/intern/implicit_blender.c
index 9ae5329..76b1e35 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/physics/intern/implicit_blender.c
@@ -26,7 +26,7 @@
  */
 
 /** \file blender/blenkernel/intern/implicit.c
- *  \ingroup bke
+ *  \ingroup bph
  */
 
 #include "implicit.h"
@@ -50,6 +50,8 @@
 #include "BKE_effect.h"
 #include "BKE_global.h"
 
+#include "BPH_mass_spring.h"
+
 #ifdef __GNUC__
 #  pragma GCC diagnostic ignored "-Wtype-limits"
 #endif
diff --git a/source/blender/blenkernel/intern/implicit_eigen.cpp b/source/blender/physics/intern/implicit_eigen.cpp
similarity index 99%
rename from source/blender/blenkernel/intern/implicit_eigen.cpp
rename to source/blender/physics/intern/implicit_eigen.cpp
index 863c715..230ca6f 100644
--- a/source/blender/blenkernel/intern/implicit_eigen.cpp
+++ b/source/blender/physics/intern/implicit_eigen.cpp
@@ -26,7 +26,7 @@
  */
 
 /** \file blender/blenkernel/intern/implicit_eigen.cpp
- *  \ingroup bke
+ *  \ingroup bph
  */
 
 #include "implicit.h"
@@ -75,6 +75,8 @@ extern "C" {
 #include "BKE_collision.h"
 #include "BKE_effect.h"
 #include "BKE_global.h"
+
+#include "BPH_mass_spring.h"
 }
 
 /* ==== hash functions for debugging ==== */
diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c
index e60cf02..a6feea9 100644
--- a/source/blender/render/intern/source/voxeldata.c
+++ b/source/blender/render/intern/source/voxeldata.c
@@ -381,7 +381,8 @@ static void init_frame_hair(VoxelData *vd, int UNUSED(cfra))
 		ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
 		
 		if (pmd->psys && pmd->psys->clmd) {
-			found |= implicit_hair_volume_get_texture_data(ob, pmd->psys->clmd, NULL, vd);
+			// XXX TODO was moved into own subfolder, figure out how to handle this (perhaps make a wrapper in BKE)
+//			found |= implicit_hair_volume_get_texture_data(ob, pmd->psys->clmd, NULL, vd);
 		}
 	}




More information about the Bf-blender-cvs mailing list