Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) Blender Foundation. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): Daniel Genrich 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 #ifndef BKE_COLLISIONS_H 00028 #define BKE_COLLISIONS_H 00029 00035 #include <math.h> 00036 #include <float.h> 00037 #include <stdlib.h> 00038 #include <string.h> 00039 00040 /* types */ 00041 #include "BKE_collision.h" 00042 #include "DNA_cloth_types.h" 00043 00044 #include "BLI_kdopbvh.h" 00045 00046 struct Cloth; 00047 struct ClothModifierData; 00048 struct CollisionModifierData; 00049 struct DerivedMesh; 00050 struct Group; 00051 struct MFace; 00052 struct MVert; 00053 struct Object; 00054 struct Scene; 00055 struct LinkNode; 00056 00058 // used for collisions in collision.c 00060 00061 /* COLLISION FLAGS */ 00062 typedef enum 00063 { 00064 COLLISION_IN_FUTURE = (1 << 1), 00065 #ifdef WITH_ELTOPO 00066 COLLISION_USE_COLLFACE = (1 << 2), 00067 COLLISION_IS_EDGES = (1 << 3), 00068 #endif 00069 } COLLISION_FLAGS; 00070 00071 00073 // used for collisions in collision.c 00075 /* used for collisions in collision.c */ 00076 typedef struct CollPair 00077 { 00078 unsigned int face1; // cloth face 00079 unsigned int face2; // object face 00080 double distance; // magnitude of vector 00081 float normal[3]; 00082 float vector[3]; // unnormalized collision vector: p2-p1 00083 float pa[3], pb[3]; // collision point p1 on face1, p2 on face2 00084 int flag; 00085 float time; // collision time, from 0 up to 1 00086 #ifdef WITH_ELTOPO /*either ap* or bp* can be set, but not both*/ 00087 float bary[3]; 00088 int ap1, ap2, ap3, collp, bp1, bp2, bp3; 00089 int collface; 00090 #else 00091 int ap1, ap2, ap3, bp1, bp2, bp3; 00092 #endif 00093 int pointsb[4]; 00094 } 00095 CollPair; 00096 00097 /* used for collisions in collision.c */ 00098 typedef struct EdgeCollPair 00099 { 00100 unsigned int p11, p12, p21, p22; 00101 float normal[3]; 00102 float vector[3]; 00103 float time; 00104 int lastsign; 00105 float pa[3], pb[3]; // collision point p1 on face1, p2 on face2 00106 } 00107 EdgeCollPair; 00108 00109 /* used for collisions in collision.c */ 00110 typedef struct FaceCollPair 00111 { 00112 unsigned int p11, p12, p13, p21; 00113 float normal[3]; 00114 float vector[3]; 00115 float time; 00116 int lastsign; 00117 float pa[3], pb[3]; // collision point p1 on face1, p2 on face2 00118 } 00119 FaceCollPair; 00120 00122 00123 00124 00126 // forward declarations 00128 00130 // used in modifier.c from collision.c 00132 00133 BVHTree *bvhtree_build_from_mvert ( struct MFace *mfaces, unsigned int numfaces, struct MVert *x, unsigned int numverts, float epsilon ); 00134 void bvhtree_update_from_mvert ( BVHTree * bvhtree, struct MFace *faces, int numfaces, struct MVert *x, struct MVert *xnew, int numverts, int moving ); 00135 00137 00138 struct LinkNode *BLI_linklist_append_fast ( struct LinkNode **listp, void *ptr ); 00139 00140 // move Collision modifier object inter-frame with step = [0,1] 00141 // defined in collisions.c 00142 void collision_move_object ( struct CollisionModifierData *collmd, float step, float prevstep ); 00143 00144 // interface for collision functions 00145 void collisions_compute_barycentric ( float pv[3], float p1[3], float p2[3], float p3[3], float *w1, float *w2, float *w3 ); 00146 void interpolateOnTriangle ( float to[3], float v1[3], float v2[3], float v3[3], double w1, double w2, double w3 ); 00147 00149 // used in effect.c 00151 struct Object **get_collisionobjects(struct Scene *scene, struct Object *self, struct Group *group, unsigned int *numcollobj); 00152 00153 typedef struct ColliderCache { 00154 struct ColliderCache *next, *prev; 00155 struct Object *ob; 00156 struct CollisionModifierData *collmd; 00157 } ColliderCache; 00158 00159 struct ListBase *get_collider_cache(struct Scene *scene, struct Object *self, struct Group *group); 00160 void free_collider_cache(struct ListBase **colliders); 00161 00163 00164 00165 00167 00168 #endif 00169