[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13148] branches/cloth/blender: Merged back with last version where collisions worked at least a bit ( rev 12296).
Daniel Genrich
daniel.genrich at gmx.net
Mon Jan 7 04:20:46 CET 2008
Revision: 13148
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13148
Author: genscher
Date: 2008-01-07 04:20:43 +0100 (Mon, 07 Jan 2008)
Log Message:
-----------
Merged back with last version where collisions worked at least a bit (rev 12296). Also merged fixes (hopefully).
Revision Links:
--------------
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12296
Modified Paths:
--------------
branches/cloth/blender/CMakeLists.txt
branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
branches/cloth/blender/source/blender/blenkernel/BKE_modifier.h
branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
branches/cloth/blender/source/blender/blenkernel/intern/collision.c
branches/cloth/blender/source/blender/blenkernel/intern/implicit.c
branches/cloth/blender/source/blender/blenkernel/intern/modifier.c
branches/cloth/blender/source/blender/blenloader/intern/readfile.c
branches/cloth/blender/source/blender/blenloader/intern/writefile.c
branches/cloth/blender/source/blender/makesdna/DNA_cloth_types.h
branches/cloth/blender/source/blender/makesdna/DNA_modifier_types.h
branches/cloth/blender/source/blender/src/buttons_object.c
branches/cloth/blender/source/blender/src/drawobject.c
branches/cloth/blender/source/blender/src/vpaint.c
Modified: branches/cloth/blender/CMakeLists.txt
===================================================================
--- branches/cloth/blender/CMakeLists.txt 2008-01-07 00:59:09 UTC (rev 13147)
+++ branches/cloth/blender/CMakeLists.txt 2008-01-07 03:20:43 UTC (rev 13148)
@@ -65,8 +65,9 @@
OPTION(WITH_QUICKTIME "Enable Quicktime Support" OFF)
OPTION(WITH_OPENEXR "Enable OpenEXR Support (http://www.openexr.com)" OFF)
OPTION(WITH_FFMPEG "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF)
-OPTION(WITH_OPENAL "Enable OpenAL Support (http://www.openal.org)" ON)
-OPTION(YESIAMSTUPID "Enable execution on 64-bit platforms" OFF)
+OPTION(WITH_OPENAL "Enable OpenAL Support (http://www.openal.org)" ON)
+OPTION(YESIAMSTUPID "Enable execution on 64-bit platforms" OFF)
+OPTION(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" OFF)
IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
@@ -184,6 +185,13 @@
SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++")
+ IF(WITH_OPENMP)
+ SET(LLIBS "${LLIBS} -lgomp ")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp ")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp ")
+ ENDIF(WITH_OPENMP)
+
+
SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -DXP_UNIX -Wno-char-subscripts")
SET(PLATFORM_LINKFLAGS "-pthread")
@@ -270,6 +278,11 @@
SET(CMAKE_C_FLAGS_MINSIZEREL "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+ IF(WITH_OPENMP)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp ")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp ")
+ ENDIF(WITH_OPENMP)
+
SET(SDL ${LIBDIR}/sdl)
SET(SDL_INC ${SDL}/include)
SET(SDL_LIB SDL)
@@ -347,6 +360,12 @@
SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
+ IF(WITH_OPENMP)
+ SET(LLIBS "${LLIBS} -lgomp ")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp ")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp ")
+ ENDIF(WITH_OPENMP)
+
SET(SDL ${LIBDIR}/sdl)
SET(SDL_INC ${SDL}/include)
SET(SDL_LIB SDL)
Modified: branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h 2008-01-07 00:59:09 UTC (rev 13147)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h 2008-01-07 03:20:43 UTC (rev 13148)
@@ -34,14 +34,14 @@
#ifndef BKE_CLOTH_H
#define BKE_CLOTH_H
-#include "BKE_customdata.h"
#include "BLI_linklist.h"
+#include "BKE_customdata.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_object.h"
-
#include "DNA_cloth_types.h"
#include "DNA_customdata_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
struct Object;
struct Cloth;
@@ -49,8 +49,8 @@
struct DerivedMesh;
struct ClothModifierData;
-// this is needed for inlining behaviour
+// this is needed for inlining behaviour
#ifndef _WIN32
#define LINUX
#define DO_INLINE inline
@@ -60,72 +60,7 @@
#define CLOTH_MAX_THREAD 2
-typedef struct fc
-{
- float *d, *d0; // density
- float *T, *T0; // temperature
- float *u, *u0; // velocity in x direction
- float *v, *v0; // velocity in y direction
- float *w, *w0; // velocity in z direction
- unsigned char* _texture_data;
- float _light_dir[3];
- int _ray_templ[4096][3];
- FILE* _fp;
- int _cur_frame;
- int _nframes;
-} fc;
-fc *f_init(void);
-void f_free(fc *m_fc);
-void step(fc *m_fc, float dt);
-
-typedef struct ClothVertex {
- int flags; /* General flags per vertex. */
- float mass; /* mass / weight of the vertex */
- float goal; /* goal, from SB */
- float impulse[3]; /* used in collision.c */
- unsigned int impulse_count; /* same as above */
- float collball;
- char octantflag;
- float weight;
-} ClothVertex;
-
-typedef struct ClothSpring {
- unsigned int ij; /* Pij from the paper, one end of the spring. */
- unsigned int kl; /* Pkl from the paper, one end of the spring. */
- float restlen; /* The original length of the spring. */
- unsigned int matrix_index; /* needed for implicit solver (fast lookup) */
- int type; /* types defined in BKE_cloth.h ("springType") */
- int flags; /* defined in BKE_cloth.h, e.g. deactivated due to tearing */
- float dfdx[3][3];
- float dfdv[3][3];
- float f[3];
-} ClothSpring;
-
-typedef struct Cloth {
- struct ClothVertex *verts; /* The vertices that represent this cloth. */
- struct LinkNode *springs; /* The springs connecting the mesh. */
- struct BVH *tree; /* collision tree for this cloth object */
- struct BVH *selftree; /* self collision tree for this cloth object */
- struct MFace *mfaces;
- struct Implicit_Data *implicit; /* our implicit solver connects to this pointer */
- struct EdgeHash *edgehash; /* used for fast checking adjacent points */
- unsigned int numverts; /* The number of verts == m * n. */
- unsigned int numsprings; /* The count of springs. */
- unsigned int numfaces;
- unsigned int numothersprings;
- unsigned int numspringssave;
- unsigned int old_solver_type;
- float (*x)[3]; /* The current position of all vertices.*/
- float (*xold)[3]; /* The previous position of all vertices.*/
- float (*current_x)[3]; /* The TEMPORARY current position of all vertices.*/
- float (*current_xold)[3]; /* The TEMPORARY previous position of all vertices.*/
- float (*v)[4]; /* the current velocity of all vertices */
- float (*current_v)[3];
- float (*xconst)[3];
- struct fc *m_fc;
-} Cloth;
-
/* goal defines */
#define SOFTGOALSNAP 0.999f
@@ -155,9 +90,7 @@
CLOTH_SIMSETTINGS_FLAG_COLLOBJ = ( 1 << 2 ), // object is only collision object, no cloth simulation is done
CLOTH_SIMSETTINGS_FLAG_GOAL = ( 1 << 3 ), // we have goals enabled
CLOTH_SIMSETTINGS_FLAG_TEARING = ( 1 << 4 ), // true if tearing is enabled
- CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT = ( 1 << 5 ),
- CLOTH_SIMSETTINGS_FLAG_BIG_FORCE = ( 1 << 6 ), // true if we have big spring force for bending
- CLOTH_SIMSETTINGS_FLAG_SLEEP = ( 1 << 7 ), // true if we let the cloth go to sleep
+ CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT = ( 1 << 5 ), // true if tearing is enabled
} CLOTH_SIMSETTINGS_FLAGS;
/* SPRING FLAGS */
@@ -172,7 +105,6 @@
CLOTH_SPRING_TYPE_STRUCTURAL = 0,
CLOTH_SPRING_TYPE_SHEAR,
CLOTH_SPRING_TYPE_BENDING,
- CLOTH_SPRING_TYPE_COLLISION,
} CLOTH_SPRING_TYPES;
/* SPRING FLAGS */
@@ -188,32 +120,91 @@
// needed for buttons_object.c
-void cloth_clear_cache(struct Object *ob, struct ClothModifierData *clmd, float framenr);
-void cloth_free_modifier ( struct ClothModifierData *clmd );
+void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr);
// needed for cloth.c
-void implicit_set_positions ( struct ClothModifierData *clmd );
+void implicit_set_positions ( ClothModifierData *clmd );
// from cloth.c, needed for modifier.c
-DerivedMesh *clothModifier_do(struct ClothModifierData *clmd, struct Object *ob, struct DerivedMesh *dm, int useRenderParams, int isFinalCalc);
+void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm, float ( *vertexCos ) [3], int numverts );
-// needed in implicit.c
-int cloth_bvh_objcollision(struct ClothModifierData *clmd, float step, float prevstep, float dt);
+// used in collision.c
+typedef struct Tree
+{
+ struct Tree *nodes[4]; // 4 children --> quad-tree
+ struct Tree *parent;
+ struct Tree *nextLeaf;
+ struct Tree *prevLeaf;
+ float bv[26]; // Bounding volume of all nodes / we have 7 axes on a 14-DOP
+ unsigned int tri_index; // this saves the index of the face
+ int count_nodes; // how many nodes are used
+ int traversed; // how many nodes already traversed until this level?
+ int isleaf;
+}
+Tree;
+typedef struct Tree TreeNode;
+
+typedef struct BVH
+{
+ unsigned int numfaces;
+ unsigned int numverts;
+ ClothVertex *verts; // just a pointer to the original datastructure
+ MFace *mfaces; // just a pointer to the original datastructure
+ struct LinkNode *tree;
+ TreeNode *root; // TODO: saving the root --> is this really needed? YES!
+ TreeNode *leaf_tree; /* Tail of the leaf linked list. */
+ TreeNode *leaf_root; /* Head of the leaf linked list. */
+ float epsilon; /* epslion is used for inflation of the k-dop */
+ int flags; /* bvhFlags */
+}
+BVH;
+
+typedef void ( *CM_COLLISION_RESPONSE ) ( ClothModifierData *clmd, ClothModifierData *coll_clmd, Tree * tree1, Tree * tree2 );
+
+
+/////////////////////////////////////////////////
+// collision.c
////////////////////////////////////////////////
+// needed for implicit.c
+void bvh_collision_response ( ClothModifierData *clmd, ClothModifierData *coll_clmd, Tree * tree1, Tree * tree2 );
+int cloth_bvh_objcollision ( ClothModifierData * clmd, float step, float dt );
+////////////////////////////////////////////////
+
+
/////////////////////////////////////////////////
+// kdop.c
+////////////////////////////////////////////////
+
+// needed for cloth.c
+void bvh_free ( BVH * bvh );
+BVH *bvh_build ( ClothModifierData *clmd, float epsilon );
+LinkNode *BLI_linklist_append_fast ( LinkNode **listp, void *ptr );
+
+// needed for collision.c
+int bvh_traverse ( ClothModifierData * clmd, ClothModifierData * coll_clmd, Tree * tree1, Tree * tree2, float step, CM_COLLISION_RESPONSE collision_response );
+void bvh_update ( ClothModifierData * clmd, BVH * bvh, int moving );
+
+////////////////////////////////////////////////
+
+
+
+/////////////////////////////////////////////////
// cloth.c
////////////////////////////////////////////////
-void cloth_free_modifier ( struct ClothModifierData *clmd );
-void cloth_init ( struct ClothModifierData *clmd );
+void cloth_free_modifier ( ClothModifierData *clmd );
+void cloth_init ( ClothModifierData *clmd );
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list