[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13357] branches/cloth/blender/source/ blender: GUI cloth panel refactor, also made many code rearrangements, cleared DNA up
Daniel Genrich
daniel.genrich at gmx.net
Tue Jan 22 21:28:12 CET 2008
Revision: 13357
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13357
Author: genscher
Date: 2008-01-22 21:28:12 +0100 (Tue, 22 Jan 2008)
Log Message:
-----------
GUI cloth panel refactor, also made many code rearrangements, cleared DNA up
Modified Paths:
--------------
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
Modified: branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h 2008-01-22 19:55:51 UTC (rev 13356)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h 2008-01-22 20:28:12 UTC (rev 13357)
@@ -35,6 +35,7 @@
#define BKE_CLOTH_H
#include "BLI_linklist.h"
+#include "BKE_collision.h"
#include "BKE_customdata.h"
#include "BKE_DerivedMesh.h"
#include "DNA_cloth_types.h"
@@ -48,8 +49,8 @@
struct MFace;
struct DerivedMesh;
struct ClothModifierData;
+struct CollisionTree;
-
// this is needed for inlining behaviour
#ifndef _WIN32
#define LINUX
@@ -60,7 +61,6 @@
#define CLOTH_MAX_THREAD 2
-
/**
* Pin and unpin frames are the frames on which the vertices stop moving.
* They will assume the position they had prior to pinFrame until unpinFrame
@@ -169,42 +169,9 @@
// from cloth.c, needed for modifier.c
void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm, float ( *vertexCos ) [3], int numverts );
-// used in collision.c
-typedef struct CollisionTree
-{
- struct CollisionTree *nodes[4]; // 4 children --> quad-tree
- struct CollisionTree *parent;
- struct CollisionTree *nextLeaf;
- struct CollisionTree *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 point_index[4]; // supports up to 4 points in a leaf
- int count_nodes; // how many nodes are used
- int traversed; // how many nodes already traversed until this level?
- int isleaf;
-}
-CollisionTree;
+typedef void ( *CM_COLLISION_RESPONSE ) ( ClothModifierData *clmd, CollisionModifierData *collmd, CollisionTree *tree1, CollisionTree *tree2 );
-typedef struct BVH
-{
- unsigned int numfaces;
- unsigned int numverts;
- // ClothVertex *verts; // just a pointer to the original datastructure
- MVert *current_x; // e.g. txold in clothvertex
- MVert *current_xold; // e.g. tx in clothvertex
- MFace *mfaces; // just a pointer to the original datastructure
- struct LinkNode *tree;
- CollisionTree *root; // TODO: saving the root --> is this really needed? YES!
- CollisionTree *leaf_tree; /* Tail of the leaf linked list. */
- CollisionTree *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, CollisionModifierData *collmd, CollisionTree * tree1, CollisionTree * tree2 );
-
-
/////////////////////////////////////////////////
// collision.c
////////////////////////////////////////////////
@@ -213,31 +180,21 @@
void bvh_collision_response ( ClothModifierData *clmd, ClothModifierData *coll_clmd, CollisionTree * tree1, CollisionTree * tree2 );
int cloth_bvh_objcollision ( ClothModifierData * clmd, float step, float dt );
-// needed for modifier.c
-BVH *bvh_build_from_mvert (MFace *mfaces, unsigned int numfaces, MVert *x, unsigned int numverts, float epsilon);
-
-// needed for collision.c
-void bvh_update_from_mvert(BVH * bvh, MVert *x, unsigned int numverts, MVert *xnew, int moving);
-
+int bvh_traverse ( ClothModifierData * clmd, CollisionModifierData * collmd, CollisionTree * tree1, CollisionTree * tree2, float step, CM_COLLISION_RESPONSE collision_response );
////////////////////////////////////////////////
-/////////////////////////////////////////////////
-// kdop.c
////////////////////////////////////////////////
-
+// implicit.c
+////////////////////////////////////////////////
+
// needed for cloth.c
-void bvh_free ( BVH * bvh );
-void bvh_build (BVH *bvh);
-LinkNode *BLI_linklist_append_fast ( LinkNode **listp, void *ptr );
-
-// needed for collision.c
-int bvh_traverse ( ClothModifierData * clmd, CollisionModifierData * collmd, CollisionTree * tree1, CollisionTree * tree2, float step, CM_COLLISION_RESPONSE collision_response );
-void bvh_update(BVH * bvh, int moving);
+int implicit_init ( Object *ob, ClothModifierData *clmd );
+int implicit_free ( ClothModifierData *clmd );
+int implicit_solver ( Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors );
////////////////////////////////////////////////
-
/////////////////////////////////////////////////
// cloth.c
////////////////////////////////////////////////
@@ -276,12 +233,6 @@
}
CM_SOLVER_DEF;
-
-/* new C implicit simulator */
-int implicit_init ( Object *ob, ClothModifierData *clmd );
-int implicit_free ( ClothModifierData *clmd );
-int implicit_solver ( Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors );
-
/* used for caching in implicit.c */
typedef struct Frame
{
@@ -292,45 +243,5 @@
}
Frame;
-/* used for collisions in collision.c */
-typedef struct CollPair
-{
- unsigned int face1; // cloth face
- unsigned int face2; // object face
- double distance; // magnitude of vector
- float normal[3];
- float vector[3]; // unnormalized collision vector: p2-p1
- float pa[3], pb[3]; // collision point p1 on face1, p2 on face2
- int lastsign; // indicates if the distance sign has changed, unused itm
- float time; // collision time, from 0 up to 1
- unsigned int ap1, ap2, ap3, bp1, bp2, bp3, bp4;
- unsigned int pointsb[4];
-}
-CollPair;
-
-/* used for collisions in collision.c */
-typedef struct EdgeCollPair
-{
- unsigned int p11, p12, p21, p22;
- float normal[3];
- float vector[3];
- float time;
- int lastsign;
- float pa[3], pb[3]; // collision point p1 on face1, p2 on face2
-}
-EdgeCollPair;
-
-/* used for collisions in collision.c */
-typedef struct FaceCollPair
-{
- unsigned int p11, p12, p13, p21;
- float normal[3];
- float vector[3];
- float time;
- int lastsign;
- float pa[3], pb[3]; // collision point p1 on face1, p2 on face2
-}
-FaceCollPair;
-
#endif
Modified: branches/cloth/blender/source/blender/blenkernel/BKE_modifier.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_modifier.h 2008-01-22 19:55:51 UTC (rev 13356)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_modifier.h 2008-01-22 20:28:12 UTC (rev 13357)
@@ -287,7 +287,7 @@
int *lastPossibleCageIndex_r);
int modifiers_isSoftbodyEnabled(struct Object *ob);
-ModifierData * modifiers_isClothEnabled(Object *ob);
+ClothModifierData * modifiers_isClothEnabled(Object *ob);
int modifiers_isParticleEnabled(struct Object *ob);
struct Object *modifiers_isDeformedByArmature(struct Object *ob);
Modified: branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/cloth.c 2008-01-22 19:55:51 UTC (rev 13356)
+++ branches/cloth/blender/source/blender/blenkernel/intern/cloth.c 2008-01-22 20:28:12 UTC (rev 13357)
@@ -141,46 +141,46 @@
* 2. fill object with standard values or with the GUI settings if given
*/
void cloth_init ( ClothModifierData *clmd )
-{
+{
/* Initialize our new data structure to reasonable values. */
- clmd->sim_parms.gravity [0] = 0.0;
- clmd->sim_parms.gravity [1] = 0.0;
- clmd->sim_parms.gravity [2] = -9.81;
- clmd->sim_parms.structural = 100.0;
- clmd->sim_parms.shear = 100.0;
- clmd->sim_parms.bending = 1.0;
- clmd->sim_parms.Cdis = 5.0;
- clmd->sim_parms.Cvi = 1.0;
- clmd->sim_parms.mass = 1.0f;
- clmd->sim_parms.stepsPerFrame = 5;
- clmd->sim_parms.sim_time = 1.0;
- clmd->sim_parms.flags = CLOTH_SIMSETTINGS_FLAG_RESET;
- clmd->sim_parms.solver_type = 0;
- clmd->sim_parms.preroll = 0;
- clmd->sim_parms.maxspringlen = 10;
- clmd->sim_parms.firstframe = 1;
- clmd->sim_parms.lastframe = 250;
- clmd->sim_parms.vgroup_mass = 0;
- clmd->coll_parms.self_friction = 5.0;
- clmd->coll_parms.friction = 10.0;
- clmd->coll_parms.loop_count = 1;
- clmd->coll_parms.epsilon = 0.01f;
- clmd->coll_parms.flags = 0;
+ clmd->sim_parms->gravity [0] = 0.0;
+ clmd->sim_parms->gravity [1] = 0.0;
+ clmd->sim_parms->gravity [2] = -9.81;
+ clmd->sim_parms->structural = 100.0;
+ clmd->sim_parms->shear = 100.0;
+ clmd->sim_parms->bending = 1.0;
+ clmd->sim_parms->Cdis = 5.0;
+ clmd->sim_parms->Cvi = 1.0;
+ clmd->sim_parms->mass = 1.0f;
+ clmd->sim_parms->stepsPerFrame = 5;
+ clmd->sim_parms->sim_time = 1.0;
+ clmd->sim_parms->flags = CLOTH_SIMSETTINGS_FLAG_RESET;
+ clmd->sim_parms->solver_type = 0;
+ clmd->sim_parms->preroll = 0;
+ clmd->sim_parms->maxspringlen = 10;
+ clmd->sim_parms->firstframe = 1;
+ clmd->sim_parms->lastframe = 250;
+ clmd->sim_parms->vgroup_mass = 0;
+ clmd->coll_parms->self_friction = 5.0;
+ clmd->coll_parms->friction = 10.0;
+ clmd->coll_parms->loop_count = 1;
+ clmd->coll_parms->epsilon = 0.01f;
+ clmd->coll_parms->flags = 0;
/* These defaults are copied from softbody.c's
* softbody_calc_forces() function.
*/
- clmd->sim_parms.eff_force_scale = 1000.0;
- clmd->sim_parms.eff_wind_scale = 250.0;
+ clmd->sim_parms->eff_force_scale = 1000.0;
+ clmd->sim_parms->eff_wind_scale = 250.0;
// also from softbodies
- clmd->sim_parms.maxgoal = 1.0f;
- clmd->sim_parms.mingoal = 0.0f;
- clmd->sim_parms.defgoal = 0.0f;
- clmd->sim_parms.goalspring = 100.0f;
- clmd->sim_parms.goalfrict = 0.0f;
+ clmd->sim_parms->maxgoal = 1.0f;
+ clmd->sim_parms->mingoal = 0.0f;
+ clmd->sim_parms->defgoal = 0.0f;
+ clmd->sim_parms->goalspring = 100.0f;
+ clmd->sim_parms->goalfrict = 0.0f;
- clmd->sim_parms.cache = NULL;
+ clmd->sim_parms->cache = NULL;
}
@@ -488,7 +488,7 @@
{
int stack_index = -1;
- if(!(clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT))
+ if(!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT))
{
stack_index = modifiers_indexInObject(ob, (ModifierData *)clmd);
@@ -557,7 +557,7 @@
fclose(fp);
}
- if(clmd->sim_parms.solver_type == 0)
+ if(clmd->sim_parms->solver_type == 0)
implicit_set_positions(clmd);
return ret;
@@ -585,21 +585,21 @@
ClothVertex *newframe= NULL, *verts;
Frame *frame = NULL;
LinkNode *search = NULL;
- float deltaTime = current_time - clmd->sim_parms.sim_time;
+ float deltaTime = current_time - clmd->sim_parms->sim_time;
- clmd->sim_parms.ob = ob;
+ clmd->sim_parms->ob = ob;
// only be active during a specific period:
// that's "first frame" and "last frame" on GUI
/*
- if ( ! ( clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ ) )
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list